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