-
-
Save 19h/3151702 to your computer and use it in GitHub Desktop.
| vdrld = function (a, b) { // We do not get the video-id nor do we get any url; that is, we extract the ID from the image-url. | |
| vdldr = Ti.Network.createHTTPClient(); | |
| vdldr.onload = function () { | |
| x = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(this.responseText)))); | |
| x = x.split(",url="); | |
| q = []; | |
| types = []; | |
| vcl = function (a) { | |
| return a.split("&itag")[0] | |
| }; | |
| for (y in x) | |
| if ( "http:" == x[y].substring(0, 5) && "mp4" == x[y].split(';+codecs="')[0].split("video/")[1] ) | |
| return b(x[y].split(';+codecs="')[0]); | |
| }; | |
| vdldr.open("GET", "http://www.youtube.com/get_video_info?video_id=" + a); | |
| vdldr.send() | |
| }; | |
| setTimeout(function(){ | |
| vdrld("FGAyjfwK-wI", function () { | |
| return Titanium.App.fireEvent("playvideo", {url: arguments[0]}); | |
| }); | |
| }, 5000); |
How would one implement this in Java? :D Thanks.
But it will work for youtube only.
In my app case, video url is not fixed it can be youtube/vimeo/espn etc.
So what should I do for it. I have video url only and on basis of that url I need to play that video.
This is holy awesome... excellent :D
Estimado no encuentro esta sección en la respuesta fmt_stream_map ante eso comos e puede proceder??
As of yesterday I got an error saying it couldn't parse the object.
I edited this piece of code:
vdldr = Ti.Network.createHTTPClient();
vdldr.onload = function () {
x = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(this.responseText.substring(4, this.responseText.length)))));
y = JSON.parse(x).content.video["fmt_stream_map"][0].url;
return b(y);
};
to:
vdldr = Ti.Network.createHTTPClient();
vdldr.onload = function () {
y = JSON.parse(decodeURIComponent(this.responseText.substring(4, this.responseText.length))).content.video["fmt_stream_map"][0].url;
return b(y);
};
And it worked again!
hi! fmt_stream_map doesnt find in android! any suggestions?
hey that youtube code posted by khallouki again sttoped working plz help me .
can any one please tell me why that code stops working.
Format of the JSON returned by YouTube seems to have changed. fmt_stream_map now seems to be within a 'player_data' object instead of the 'video' object.
Try replacing:
this.responseText.length))).content.video["fmt_stream_map"][0].url;
with
this.responseText.length))).content.player_data["fmt_stream_map"][0].url;
hey thanks its working again...
Does it work in Android also? Seems not
I've got a return failed parse JSON
and I've fix with change
x = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(this.responseText.substring(4, this.responseText.length)))));
y = JSON.parse(x).content.video["fmt_stream_map"][0].url;
to:
x = this.responseText.substring(4, this.responseText.length);
y = JSON.parse(x).content.player_data["fmt_stream_map"][0].url;
I just remove "decodeURIComponent"
It's work on good on iOS simulator and device. not yet test on android.
ademahendra?
I had the same problem that you and I did the same change you did and I get an error:
"Unable to parse JSON atring at line 60".
This is my line 60:
"y = JSON.parse(x).content.player_data["fmt_stream_map"][0].url;"
What do you suggest that I can do?
Thank you.
I already tried this codes:
var vidWin = Titanium.UI.createWindow({
title : 'Video View Demo',
backgroundColor : '#fff'
});
// check for network
if (Titanium.Network.networkType === Titanium.Network.NETWORK_NONE) {
Titanium.API.info(' no connection ');
} else {
Titanium.API.info(' connection present ');
}
var videoPlayer = Titanium.Media.createVideoPlayer({
top : 50,
autoplay : true,
backgroundColor : 'blue',
height : 300,
width : 300,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
videoPlayer.url = 'http://www.youtube.com/watch?v=7yTGXoHsHws'; // replace this url with your video url
vidWin.add(videoPlayer);
vidWin.open();
And almost make the video run... The problem is that appears a loading icon running but the video doesn't play!
To play videos from youtube all video has to load before, using Titanium? I don't think so, right?
Kenan... Any tips on how to fix your script to work with YouTube's V3 API??
Thanks!!!
This is so awesome. Thank you so much!