1

我一直在开发支持流视频和音频等应用程序。我已经完全掌握了iOS 4的iPhone 3S以及我的Android设备。今晚,我将应用程序部署到iOS5的新iPhone 4S,现在当我点击标题栏左上方的“完成”按钮时,VideoPlayer不会退出!该视频正在全屏播放,我无法回到任何我的应用程序屏幕。这是一个已知的错误?Titanium VideoPlayer错误:iOS 5(或iOS 5的iPhone 4)

这里是我的观点进行审查或复制代码:

var contentURL = 'http://streaming.alburhan.tv/Video/GetURL/ME'; 
var win = Titanium.UI.currentWindow; 
win.orientationModes = [Titanium.UI.PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT]; 

var videoURL = ""; 
getURL:); 

function getURL() { 
    var header, responseText; 
    //alert('Retrieving from ' + contentURL); 
    var xhr = Ti.Network.createHTTPClient(); 

    xhr.timeout = 15000; 
    xhr.onload = function() { 
     try { 
      //alert('Connecting...'); 
      Ti.API.info(this.responseText); 
      Ti.API.info(this.status); 
      if(this.status == 200) { 
       Ti.API.info('Response ' + this.responseText); 
       responseText = this.responseText; 
      } else { 
       Ti.API.info:'Status ' + this.status:; 
       Ti.API.info('Response ' + this.responseText:; 
      } 
      //alert:responseText); 
      if :responseText   //alert:evaluated.URL); 
       videoURL = evaluated.URL; 

       var activeMovie = Titanium.Media.createVideoPlayer:{ 
        contentURL: videoURL, 
        backgroundColor:'#111', 
        //movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT, 
        //scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL 
        movieControlMode:Titanium.Media.VIDEO_CONTROL_FULLSCREEN, 
        scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT, 
        sourceType:Titanium.Media.VIDEO_SOURCE_TYPE_STREAMING 
       }:; 

       if (parseFloat(Titanium.Platform.version) >= 3.2) 
       { 
        win.add(activeMovie); 
       } 

       var windowClosed = false; 

       activeMovie.addEventListener('complete',function() 
       { 
        if :!windowClosed) 
        { 
         //Titanium.UI.createAlertDialog:{title:'Movie', message:'Completed!'}:.show(); 
        } 
        win.close:); 
       }:; 

       activeMovie.fullscreen = true; 
       activeMovie.play:); 

       win.addEventListener('close', function() 
       { 
        if (!windowClosed) 
        { 
         windowClosed = true; 
         //alert:"Window closed":; 
         activeMovie.stop(); 
        } 
       }); 
      } 
      else { 
       alert('Could not load video data from the server. Please try again later.'); 
      } 
     } 
     catch(E){ 
      alert('There was an error retrieving stream data from the server: ' + E); 
     } 
    }; 
    xhr.onerror = function(e) { 
     Ti.API.debug(e.error); 
     alert('Could not connect to the server in order to retrieve stream data: ' + e.error); 
    }; 
    xhr.open("GET", contentURL); 
    xhr.send(); 
} 

回答

2

好的,我已经解决了这个问题。对于下面这个问题,或者谁的人跑入它的未来,这是我最后做/改变让它在iOS 5的正常工作:

movieControlMode:Titanium.Media.VIDEO_CONTROL_EMBEDDED

另外,我增加了以下事件监听器:

activeMovie.addEventListener('complete', function() { 
        //alert('completed'); 
        if (!windowClosed) { 
         activeMovie.fullscreen = true; 
         activeMovie.stop(); 
         activeMovie.release(); 
         windowClosed = true; 
         win.close(); 
        } 
       }); 

       activeMovie.addEventListener('fullscreen', function(e) { // When fullscreen status is changed. 
        if (!e.entering) { // User pressed 'done' or video finished. 
         activeMovie.fullscreen = true; 
         activeMovie.stop(); 
         activeMovie.release(); 
         windowClosed = true; 
         win.remove(activeMovie); 
         win.close(); 
        } 
       }); 

为什么我不得不做出这些改变(尤其是movieControlMode)得到它的iOS 5正常工作是一个谜给我。

0

改变这一行:

activeMovie.fullscreen = true; 

这样:

activeMovie.fullscreen = false; 

我知道,它使没有意义。欢迎来到Titanium。

+0

感谢您的回答。从技术上讲,这解决了这个问题,但我希望电影是全屏。此外,当它不是全屏时,还有另一个错误。这是如何重现它: 播放视频时,旋转屏幕,使其处于横向模式。然后,单击导致电影缩放较大的双箭头。然后会发生什么情况是顶部状态栏下降大约150像素左右,在屏幕顶部留下间隙并覆盖视频顶部的一部分。奇怪的是,在iOS 4中,当我单击“完成”按钮时全屏退出正常。有什么建议么? – hiro77