Titanium VideoPlayer bug:iOS 5(或带iOS 5的iPhone 4s)

时间:2011-11-10 12:35:18

标签: ios5 titanium appcelerator appcelerator-mobile titanium-mobile

我一直在开发一款支持流媒体视频和音频的应用程序。我已经通过iOS 4以及我的Android设备在iPhone 3S上完美运行了一切。今晚,我将应用程序部署到带有iOS5的新iPhone 4S,现在点击标题栏左上角的“完成”按钮后,VideoPlayer将无法退出!视频正在全屏播放,我无法返回任何应用程序屏幕。这是一个已知的错误吗?

以下是我查看或重现视图的代码:

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 个答案:

答案 0 :(得分: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上正常工作对我来说是一个谜。

答案 1 :(得分:0)

更改此行:

activeMovie.fullscreen = true;

到此:

activeMovie.fullscreen = false;

我知道,这没有任何意义。欢迎来到Titanium。