【问题标题】:Titanium VideoPlayer bug: iOS 5 (or iPhone 4s with iOS 5)Titanium VideoPlayer 错误:iOS 5(或带有 iOS 5 的 iPhone 4s)
【发布时间】:2011-11-10 12:35:17
【问题描述】:

我一直在开发一款支持流式视频和音频等功能的应用。我的 iPhone 3S 和 iOS 4 以及我的 Android 设备都可以完美运行。今晚,我将应用程序部署到我的新 iPhone 4S 和 iOS5 上,现在当我点击标题栏左上角的“完成”按钮时,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();
}

【问题讨论】:

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


    【解决方案1】:

    好的,我已经解决了这个问题。对于关注此问题或将来遇到此问题的任何人,这就是我最终要做/更改以使其在 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 上正常工作,这对我来说是个谜。

    【讨论】:

      【解决方案2】:

      改变这一行:

      activeMovie.fullscreen = true;
      

      到这里:

      activeMovie.fullscreen = false;
      

      我知道,这毫无意义。欢迎使用 Titanium。

      【讨论】:

      • 感谢您的回答。从技术上讲,这解决了这个问题,但我希望电影是全屏的。此外,当它不是全屏时,还有另一个错误。这是如何重现它:播放视频时,旋转屏幕使其处于横向模式。然后,单击使影片放大的双箭头。然后发生的情况是顶部状态栏下降了大约 150 像素左右,在屏幕顶部留下了一个间隙并覆盖了视频顶部的一部分。奇怪的是,在 iOS 4 中,当我单击“完成”按钮时,全屏退出正常。有什么建议吗?
      猜你喜欢
      • 2015-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      相关资源
      最近更新 更多