Android Streaming Video
I am hoping I am just missing something, but is it not possible to do remote streaming video with Android in Appcelerator?
It would seem that "Titanium.Media.VideoPlayer" does not accept a URL on Android… Am I doing something wrong? is there another alternative to the VideoPlayer?
3 Answers
-
if you're remote videos via vimeo, it probably will be more practical to just use a webview and pull the vimeo URL. It will handle portrait and landscape orientations for you and play pretty fast ( contingent on the internet pipe of course ) .. For my iOS version, I encoded all the vids to m4v in the amazon cloud, but this strategy has proved well working well over Droid X Device 3G, ( the webview component ) ..
use a activity indicator beforeload and load ( show() and hide() ) to give the user updated on what is going on..
-
I'm sharing my code which is working fine. Hope it will be helpful.
var win=Titanium.UI.currentWindow;
orientationModes:[Ti.UI.LANDSCAPE];
// Change to a valid URL
var contentURL = "http://assets.appcelerator.com.s3.amazonaws.com/video/media.3gp";
//var contentURL = "Aaqa Aaqa Bol Banday.MP4";var openButton = Ti.UI.createButton({
title : "Start Video",
top : "0dp",
height : "40dp",
left : "10dp",
right : "10dp"
});openButton.addEventListener('click', function() {
var activeMovie = Titanium.Media.createVideoPlayer({
url : contentURL,
backgroundColor : 'blue',
//movieControlMode : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
fullscreen : true,
autoplay : true
});
activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_EMBEDDED;
activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_FULLSCREEN;
activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_NONE;
var closeButton = Ti.UI.createButton({
title : "Exit Video",
top : "0dp",
height : "40dp",
left : "10dp",
right : "10dp"
});closeButton.addEventListener('click', function() { activeMovie.hide(); activeMovie.release(); activeMovie = null; }); activeMovie.add(closeButton);
});
win.add(openButton); -
This is Appcelerator's problem and should be fixed but not yet as of 1.5.1.
Workaround is, you can use webview and a tag to remote URL. Object tags will not run on webview in app context, though.Titanium.Platform.openURL will do if you only want to play movies, but this kicks up web browser and then video player starts so that when you stop palyback and push back button, you see blank bworser window instead of you app window.
To start movie player on click, this discussion helps a lot: http://developer.appcelerator.com/question/72361/open-pdf-file-on-android