VideoPlayer - changing the movie
I have been trying to dynamically change movies for the videoplayer to play. So instead of creating a new instance of the player I was hoping to just change the file/url property and load a new video on the fly.
There is a method called "setUrl" but it will do nothing to load a new movie. The method setMedia requires a file (or blob) object, which I cannot be able to find any documentation on how to create.
Maybe someone has gone through this exercise already. Thanks for your help.
5 Answers
-
Now you saying that, i just tried setURL and my iapp crashed, the contentURL still working despite it says "deprecated." on the DOC ref.
-
I can use contentUrl only in the constructor when creating a new videoplayer. I can't use it to dynamically change content, i.e. by setting the property. The following does not work:
MyVideoPlayer.contentUrl = 'movie.mp4';
-
I think i had the same issue, i got it to work by creating the object on the event listener instead. For Ipad, i need a view container to wrap the media object, then it dynamically on tap event.
scrollview.addEventListener('singletap', function(e) {
var s = e.source;
activeMovie = Titanium.Media.createVideoPlayer({
contentURL:s.link,
backgroundColor:'#111',
width:640,
height:392,
movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT
});
mcontainer.add(activeMovie)
activeMovie.play();
}); -
thx. Yes, creating a new player everytime you change clips works, but is not necessarily nice when changing from one clip to the next. Especially if you want a smooth transition between stop playing the first clip and start playing the next… etc. My work-around is somewhat "ugly" and includes releasing video resources before loading the next player.
-
I should add: the workaround only works in the emulator. Once you deploy to the pad there are still issues…