Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created March 25, 2015 14:25
Show Gist options
  • Save AppWerft/2fb93d07f680adf5bd64 to your computer and use it in GitHub Desktop.
Save AppWerft/2fb93d07f680adf5bd64 to your computer and use it in GitHub Desktop.
Android videoplayer
module.exports = function(_args) {
if (Ti.Network.online == false)
return;
var self = Ti.UI.createWindow({
fullscreen : true,
backgroundColor : '#444',
theme : 'Theme.NoActionBar',
orientationModes : [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT]
});
self.add(Ti.UI.createImageView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
image : 'http://i.ytimg.com/vi/' + _args.video + '/maxresdefault.jpg',
}));
require('vendor/get_yt_clip')(_args.video, function(_res) {
var videoPlayer = Ti.Media.createVideoPlayer({
autoplay : true,
url : _res.streamurl,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_MODE_FILL,
fullscreen : false,
opacity : 0,
backgroundColor : 'transparent',
// backgroundImage : meta['thumbnail_for_watch']
});
videoPlayer.addEventListener('complete', function() {
videoPlayer.release();
self.close();
});
videoPlayer.play();
self.addEventListener('close', function() {
videoPlayer.release();
});
videoPlayer.addEventListener('playbackstate', function(_e) {
console.log(_e.playbackState);
});
self.add(videoPlayer);
setTimeout(function() {
videoPlayer.animate({opacity:1});
}, 5000);
self.addEventListener("longpress", function() {
self.close();
});
});
self.open();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment