Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked May 4th 2010 by Iko Knyphausen
  • videoplayer
0 Comments

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.

    — answered May 4th 2010 by Daniel Lim
    permalink
    0 Comments
  • 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';

    — answered May 4th 2010 by Iko Knyphausen
    permalink
    0 Comments
  • 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();
    });

    — answered May 4th 2010 by Daniel Lim
    permalink
    0 Comments
  • 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.

    — answered May 4th 2010 by Iko Knyphausen
    permalink
    0 Comments
  • I should add: the workaround only works in the emulator. Once you deploy to the pad there are still issues…

    — answered May 10th 2010 by Iko Knyphausen
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.