[TIMOB-12230] added video support to media player #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
var vidWin = Titanium.UI.createWindow({
title : 'Video View Demo',
backgroundColor : 'red',
layout: 'vertical'
});
var startStopButton = Titanium.UI.createButton({
title:'Start/Stop Streaming',
top:20,
width:300
});
var pauseResumeButton = Titanium.UI.createButton({
title:'Pause/Resume Streaming',
top:20,
width:300,
enabled:false
});
var videoPlayer = Titanium.Media.createVideoPlayer({
top : 20,
height : 300,
width : 300
});
vidWin.add(startStopButton);
vidWin.add(pauseResumeButton);
startStopButton.addEventListener('click',function() {
// When paused, playing returns false.
// If both are false, playback is stopped.
if (videoPlayer.playing || videoPlayer.paused)
{
videoPlayer.stop();
pauseResumeButton.enabled = false;
videoPlayer.release();
}
else
{
videoPlayer.start();
pauseResumeButton.enabled = true;
}
});
pauseResumeButton.addEventListener('click', function() {
if (videoPlayer.paused) {
videoPlayer.start();
}
else {
videoPlayer.pause();
}
});
videoPlayer.addEventListener('progress',function(e) {
Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');
});
videoPlayer.addEventListener('change',function(e)
{
Ti.API.info('State: ' + e.description + ' (' + e.state + ')');
});
videoPlayer.addEventListener('completed',function(e)
{
Ti.API.info('media completed');
});
vidWin.addEventListener('close',function() {
});
videoPlayer.url = 'video/efencefun.mp4';
vidWin.add(videoPlayer);
vidWin.open();