Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-12230] added video support to media player #123

Merged
merged 2 commits into from Jul 12, 2013
Merged

[TIMOB-12230] added video support to media player #123

merged 2 commits into from Jul 12, 2013

Conversation

mtnlife999
Copy link
Contributor

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 + ')');

// currently blackberry does not support scaling but by hooking this
// change event and getting the actual video dimensions the developer can scale 
// or do and boxing that may be necessary
videoPlayer.width = e.videoWidth/2;
videoPlayer.height = e.videoHeight/2;

});

videoPlayer.addEventListener('completed',function(e)
{
Ti.API.info('media completed');
});

vidWin.addEventListener('close',function() {

videoPlayer.stop();
videoPlayer.release();

});

videoPlayer.url = 'video/efencefun.mp4';
vidWin.add(videoPlayer);
vidWin.open();

int NativeVideoPlayerObject::setUrl(TiObject* obj)
{
QString url = V8ValueToQString(obj->getValue());
if (url.startsWith("www.", Qt::CaseInsensitive) || url.startsWith("http://", Qt::CaseInsensitive)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one would be "https://" - notice the "s" after http

@pec1985
Copy link
Contributor

pec1985 commented Jul 11, 2013

Does this work on emulator? I only see a black screen and hear no sound.

@mtnlife999
Copy link
Contributor Author

The current BB media player is device only. So both video and audio needs to be tested on device.

@pec1985
Copy link
Contributor

pec1985 commented Jul 11, 2013

Tested on device, works as expected. Please address comments on PR at your convenience.

pec1985 added a commit that referenced this pull request Jul 12, 2013
Code reviewed and tested. Request **APPROVED**!
@pec1985 pec1985 merged commit 506f4b3 into appcelerator-archive:master Jul 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants