Titanium Community Questions & Answer Archive

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

Video behaviour on OS4 as with iOS<3.2 ?

For two apps of mine, I really prefer the videoplayer behaviour of iOS 3.1 over the one currently with iOS4. Currently I'm compiling with the older Xcode I have installed, but I would prefer to do compile to OS4 (eg to have fast app switching).
Is there any way to have the 'old' behaviour while compiling with OS4?
Or does anybody have working example code for a good-working fullscreen videoplayer on OS4?

— asked August 26th 2010 by Martijn Pannevis
  • fullscreen
  • ios3
  • ios4
  • iphone
  • player
  • video
0 Comments

3 Answers

  • Here's what i used for iphone app, worked for iOS 4, 3.1.3, ipad/3.2

    Ti.App.addEventListener('openVIDEO', function(e) {
           activewebMovie = Titanium.Media.createVideoPlayer({
               contentURL:some_remote_url_link,
           backgroundColor:'#111' 
          });
    
    if (parseFloat(Titanium.Platform.version) >= 3.2){
       var wvideo= Ti.UI.createWindow({backgroundColor:'#000',barColor:'#111'});
       wvideo.orientationModes = [Titanium.UI.LANDSCAPE_LEFT];
       wvideo.add(activewebMovie);
     }
                activewebMovie.play();  
                activewebMovie.addEventListener('complete',function(){
                activewebMovie.stop();activewebMovie.release();
                  if (parseFloat(Titanium.Platform.version) >= 3.2){
                  wvideo.orientationModes = [Titanium.UI.PORTRAIT]; 
                  wvideo.close();
                  }
           });    
    
    if (parseFloat(Titanium.Platform.version) >= 3.2){
        var closew = Titanium.UI.createButton({title:'Back',style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN});
            wvideo.setLeftNavButton(closew);
            activewebMovie.fullscreen=true;
          closew.addEventListener('click',function(){
                activewebMovie.stop();activewebMovie.release();
                 wvideo.orientationModes = [Titanium.UI.PORTRAIT];
                wvideo.close();
         });
         activewebMovie.addEventListener('fullscreen', function(e){
        if (!e.entering){
                  activewebMovie.stop();activewebMovie.release();
                 wvideo.orientationModes = [Titanium.UI.PORTRAIT];
                wvideo.close();
        }
    });
         wvideo.open({modal:true,modalTransitionStyle:Ti.UI.iPhone.MODAL_TRANSITION_STYLE_CROSS_DISSOLVE});
    }
    });
    
    — answered August 26th 2010 by Daniel Lim
    permalink
    0 Comments
  • Awesome Daniel, thanks!

    I modified your code a bit, to work with the fullscreen player from the start (I set movieControlStyle:Titanium.Media.VIDEO_CONTROL_FULLSCREEN and navBarHidden to true), as I find the 'almost fullscreen but not totally fullscreen' a bit confusing.
    I have a related question: Why do you use an eventlistener? I 'just' use a function, but I'm willing to learn if events have any advantages :).

    Thanks again, great help!
    Kind Regards,

    Martijn.

    — answered August 26th 2010 by Martijn Pannevis
    permalink
    0 Comments
  • Sort of generalized it to a global function, i have webview component and tableview triggering the videoplayer.

    — answered August 26th 2010 by Daniel Lim
    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.