YouTube in UITableView - iphone

Ok so I'm finding this insanely difficult to find for something that is done a lot. I'm struggling to find a way of putting the newest YouTube videos from a user into a UITableView.
I've tried this but it's out of date and I gets heaps of errors: http://code.google.com/p/gdata-objectivec-client/downloads/detail?name=gdata-objectivec-client-1.11.0.zip
Aside from using a UIWebView, are there any good tutorials, that work, on putting YouTube videos in a UITableView?

Let's take an example.. for Nethfel user; click on his playlist; in the link bar you will see "http://www.youtube.com/watch?v=4nx7g60Ldig&list=UUANsW00CkQnNnnUyuC1cygw"
now .. we take the playlist "number" UUANsW00CkQnNnnUyuC1cygw
and.. we will make an JSON request..max 50 results
http://gdata.youtube.com/feeds/api/playlists/UUANsW00CkQnNnnUyuC1cygw?v=2&alt=jsonc&max-results=50
You can replace JSON with JSONC - you will se minor changes in your results;
This will be your request at the beginning of your app
Now we must "interpret/translate" the next result:
{
apiVersion: "2.1",
data: {
id: "UUANsW00CkQnNnnUyuC1cygw",
author: "Nethfel",
title: "Uploaded videos",
description: "",
thumbnail: {
sqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/default.jpg",
hqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/hqdefault.jpg"
},
content: {
5: "http://www.youtube.com/p/UUANsW00CkQnNnnUyuC1cygw"
},
totalItems: 17,
startIndex: 1,
itemsPerPage: 50,
items: [
{
id: "UUGCa8nZNU7uOfDF3zV9AxkJtJSuX5gHGI",
position: 1,
author: "Nethfel",
video: {
id: "4nx7g60Ldig",
uploaded: "2011-11-02T12:32:03.000Z",
updated: "2013-01-07T18:26:41.000Z",
uploader: "nethfel",
category: "Howto",
title: "iOS Passing Data Between View Controllers Technique 1",
description: "This video discusses one of the most basic techniques for passing data between view controllers in an iOS application. This technique uses storing a local iVar in one class and passing it to the second class about to be displayed on the screen. Although this is a very simple example using an NSString, it can be applied using any other type of data as well - whether it be a collection or a custom data model object.",
thumbnail: {
sqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/default.jpg",
......
You have all the elements: title, thumbnail, link to page, etc...
you need to PARSE (extract) this JSON response.. put it in an TableView..
at click on cell, open a new "Detail" page.. were you can have LBYouTubeView for iOS

If you can get a YouTube video to play in a UIView, you can embed that in a UITableView controller cell.

Related

SWIFTUI: Filtering Lists

I am creating a task management app for my school project, and have hit a wall. My app is based off of the Scrumdinger Tutorial from my Apple to give context. I am currently trying to figure out how to filter items in the list based on two boolean values I have set for task completion, and being delted.
My tasks are structured as followed:
enter image description here
As you can see I've add the two different boolean variables that change based on button clicks within the detailView of the task.
The List of tasks is currently organized in this format, and I'm not exactly sure how to filter based on those value's within the List.
enter image description here
Tasks are stored here:
enter image description here
Any Help would be greatly appreciated!
You can try this simple solution and apply your own button logical, as you want
struct Object: Identifiable, Codable {
var id = UUID()
var taskDone: Bool
var text: String
}
#State var array = [Object(taskDone: true, text: "taskDone1"), Object(taskDone: false, text: "taskDone2")]
var body: some View {
List(array.filter { $0.taskDone }){ (item) in
Text("\(item.text)")
.foregroundColor(.red)
}
}

How can i bring an image from an api and show it in my app?

This is the api:
"page": 1,
"results": [
{
"original_language": "en",
"original_title": "Mortal Kombat",
"popularity": 2309.097,
"poster_path": "/nkayOAUBUu4mMvyNf9iHSUiPjF1.jpg",
}
This is the way I'm trying to get the image from it and saving it in a variable:
class MostPopular {
MostPopular({
this.image0,})
final String image0;
factory MostPopular.fromJson(Map<String, dynamic> json) {
final String image =
(json["results"] as List).map((j) => j["poster_path"]).toList()[0];
return MostPopular(
image0: image,)
}
}```
And when i run the app, it shows `/nkayOAUBUu4mMvyNf9iHSUiPjF1.jpg` and not the image. I tried changing the `String` but it still doesn't work and I'm not sure if thats the problem.
What you are actually getting from the api is just the image path.
However you must still append the actual base url of their domain.
From their documention,
Here's what a full image URL looks like if the poster_path of /kqjL17yufvn9OVLyXYpvtyrFfak.jpg was returned for a movie, and you were looking for the w500 size:
https://image.tmdb.org/t/p/w500/kqjL17yufvn9OVLyXYpvtyrFfak.jpg
So, change your function to this,
return MostPopular(image0: 'https://image.tmdb.org/t/p/original${image}')
and when you want to use it, you can probably use it like this,
Image.network(mostPopular.image0); // where mostPopular is an instance of MostPopular

Branch.io inetegration with cordova / ionic 1 app. Shared link generated by branch for snapchat does not show image preview and the link not clickable

We have used Branch.io for implementing deep links in our mobile hybrid app which is developed using ionic 1 framework. We have used branch-cordova-sdk plugin and configured the deep links for sharing with social media apps. We are passing title, description and contentImageUrl for branch.io to create the link. It works great on almost all SM platforms except Snapchat.
When the content is shared on snapchat, the link is showing up along with content but it is not clickable from snapchat. There is no preview of the image is shown. I could not find any solution for this yet. Also please see the code down below in reply. thanks.
Here is the code i'm using:
var branchUniversalObj = null;
var props = {};
props.canonicalIdentifier = 100;
props.title = "my title";
props.contentDescription = "my description";
props.contentImageUrl = "http://lorempixel.com/400/400/";
//create branch object
Branch.createBranchUniversalObject(props).then(function (res) {
branchUniversalObj = res
console.log('Response: ' + JSON.stringify(res))
}).catch(function (err) {
console.log('Error: ' + JSON.stringify(err))
});
Somewhere in the code:
var analytics = {
campaign: "sharing cards"
}
var properties = {
cardId : 100,
cardType: "promo",
refUser: "John"
}
// share sheet
branchUniversalObj.showShareSheet(analytics, properties, "Hello awesome stuff");
When you share a Branch link on various Social Media platforms, it is scraped to display the OG related information (i.e. OG Title, OG Image and OG Description).
When scraped, Branch will return: 1st: any OG parameters that have been defined for the link; 2nd: any OG parameters that have not been defined for the link but that have been defined at the app level (in Social Media Display Customization on the Link Settings page); and finally: any meta tags present on the web site specified in the Default URL ($fallback_url) page.
In order, to ensure that the OG image is displayed correctly, you need to ensure that you have the OG parameters defined at atleast one of the three levels mentioned above.
Here are the various ways to set OG tags
To add the og_image for a particular Quick link on the dashboard:
Visit the Quick links page on your dashboard.
Click on 'Create new Link'
On the 'Configure Options' tab and 'Social Media' section either add the og_image or the og_image_url.
While creating links from the iconic SDK add image URL to the Branch Universal Object using contentImageURL tag as shown below:
Code snippet
var properties = {
canonicalIdentifier: 'content/123',
canonicalUrl: 'https://example.com/content/123',
title: 'Content 123 Title',
contentDescription: 'Content 123 Description ' + Date.now(),
contentImageUrl: 'http://lorempixel.com/400/400/',
price: 12.12,
currency: 'GBD',
contentIndexingMode: 'private',
contentMetadata: {
custom: 'data',
testing: 123,
this_is: true
}
}
// create a branchUniversalObj variable to reference with other Branch methods
var branchUniversalObj = null
Branch.createBranchUniversalObject(properties).then(function (res) {
branchUniversalObj = res
alert('Response: ' + JSON.stringify(res))
}).catch(function (err) {
alert('Error: ' + JSON.stringify(err))
})
To set these OG tags by default for your branch links:
Go to the Link Settings Page on your dashboard:
Scroll down to the "Social Media Display Customization" section
Set the Link Title, Description and an image. Here is a screen shot for your reference.
PS: As a final caution, make sure the image you specify as the OG Image adheres to the Snapchat accepted image dimesions, which I belive is 1080 x 1920 pixels.

How to Implement Master Detail in Ionic Framework?

I am trying to use Ionic Framework to build a simple Master Detail List application. I can capture the tap event on the list item but how can I load the details view after that.
.controller('TasksController',function($scope){
$scope.tasks = [
{ title : "Collect Coins" },
{ title : "Eat Mushroom" },
{ title : "Find the princess" }
];
$scope.showTaskDetails = function() {
alert('show Task details');
}
});
In the showTaskDetails event. How can I load a different view like Details.html?
The Master Detail pattern is a very easy pattern to implement in Ionic, but you're going about it wrong. You want to set up the details as a separate view and route in your application.
I suggest reading my article on the topic.
http://mcgivery.com/ionic-master-detail-pattern/

Combobox not show the correct language values in struts1

Im using ExtJS and Struts1 for an application, when user uses this app in english and displays the combobox (inside form), the selection is in another language (spanish) but not in english. After save the form and reload the page this parameter shows in english (but if user displays the combobox again it shows in spanish). What im doing wrong to show the combobox in the correct language?.
This is what happens:
The code has more than 4k lines, this is the combobox creation, if you need more lines i dont have any problem to put here.
var storeTipoProcedimiento = new Ext.data.SimpleStore({
proxy: dameProxy( 'gestionPlanes.do' ),
autoLoad: true,
fields: [
{name: 'idTipoProcedimiento', type: 'int'},
{name: 'descripcion'}
],
baseParams: {
method: 'buscarTipoProcedimiento'
}
});
//combo para buscar los tipos de procedimientos
function dameComboTipoProcedimiento(){
var combo = new Ext.form.ComboBox({
store: storeTipoProcedimiento
,valueField: 'idTipoProcedimiento'
,fieldLabel:'<bean:message key="label.gd.tab2.tipoProc"/>'
,displayField:'descripcion'
,labelStyle: 'color: red; width: 114px;'
,fieldClass: 'padding-left: 50px;'
,mode:'local'
,triggerAction:'all'
,editable: false
,name: 'Select_Tipo'
,id: 'Select_Tipo'
,hiddenName: 'idTipo'
,width: 190
,emptyText: '<bean:message key="label.gd.tab2.tipoProc.msgElijaTipo"/>'
,listeners: {
'collapse': function(){
tipoProcedimientoId = this.value;
},
select:{fn:function(combo){
tipoProcedimientoId = combo.getValue();
}}
}
});
return combo;
}
Check the response from server. Probably the request you are doing for loading combobox is probably returning Spanish data than english data.
May be server is able to recognize the first request as right localization but for the next hit it is failing to detect. Share the code for store and proxy settings. May be we can judge by seeing that.