Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created September 23, 2019 13:24
Show Gist options
  • Save exclusiveTanim/dc347312b8d663137445655d18bc6a5d to your computer and use it in GitHub Desktop.
Save exclusiveTanim/dc347312b8d663137445655d18bc6a5d to your computer and use it in GitHub Desktop.
Corrected code for iOS 10.x.x and below
var win = Ti.UI.createWindow({
backgroundColor : 'red'
});
var label2 = Ti.UI.createLabel({
color : 'blue',
text : 'Play Video',
width : 300,
height : 200
});
label2.addEventListener('click', function(e) {
//alert('hi')
playvideo();
});
win.add(label2);
win.open();
function playvideo() {
var url = "https://storage.googleapis.com/onfvideo/Dialogue%202019/2%20compress%2006-04-2019/012%20S%20Shantakumari/Intro%20Dr%20S%20Shanthakumari.mp4";
var vidWin = Titanium.UI.createWindow({
title : 'Video View Demo',
backgroundColor : '#000000',
// top : (require('main').checkiPhoneX) ? '40dp' : require('main').isiOS7Plus() ? '20dp' : '0dp',
orientationModes : [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT, Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT]
});
vidWin.open();
var videoPlayer = Titanium.Media.createVideoPlayer({
//top : (require('main').checkiPhoneX) ? '45dp' : require('main').isiOS7Plus() ? '32dp' : '0dp',
//bottom : (require('main').checkiPhoneX) ? '32dp' : '0dp',
url : url,
autoplay : false,
fullscreen : true,
backgroundColor : '#000000',
height : Ti.UI.FILL,
width : Ti.UI.FILL,
//initialPlaybackTime : timemili,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
videoPlayer.addEventListener('complete', function(e) {
if (vidWin !== null) {
videoPlayer.hide();
videoPlayer.release();
videoPlayer = null;
vidWin.close();
vidWin = null;
}
});
vidWin.add(videoPlayer);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment