Created
May 17, 2013 20:50
-
-
Save 19h/5601881 to your computer and use it in GitHub Desktop.
Titanium Mobile SDK Android: Extract Youtube Video URL / URI from video-id / identification / name and play 3gpp file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.App.addEventListener("playvideo", function (e) { | |
win11 = Titanium.UI.createWindow({ | |
orientationModes: [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT], | |
title: "Video", | |
zIndex: 222222 | |
}); | |
var activeMovie = Titanium.Media.createVideoPlayer({ | |
fullscreen: !0, | |
autoplay: !0, | |
backgroundColor: '#111', | |
mediaControlStyle: Titanium.Media.VIDEO_CONTROL_DEFAULT, | |
scalingMode: Titanium.Media.VIDEO_SCALING_ASPECT_FIT | |
}); | |
activeMovie.url = e.url; | |
win11.add(activeMovie); | |
win11.open({ | |
fullscreen: !0 | |
}); | |
activeMovie.play(); | |
}); | |
vdrld = function (a, b) { | |
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"]; // instanceof Object | |
y = y.filter(function (v) { return v.type.split("3gpp").length > 1 })[0].url; | |
return b(y); | |
}; | |
vdldr.setRequestHeader("Referer", "http://www.youtube.com/watch?v=" + a); | |
vdldr.setRequestHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14"); | |
vdldr.open("GET", "http://m.youtube.com/watch?ajax=1&feature=related&layout=mobile&tsp=1&&v=" + a); | |
vdldr.send() | |
}; | |
setTimeout(function(){ | |
vdrld("FGAyjfwK-wI", function () { | |
return Titanium.App.fireEvent("playvideo", {url: arguments[0]}); | |
}); | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment