iPad 2视频子系统不稳定吗?

时间:2011-07-19 22:15:59

标签: ios ipad video

我正在开发一款适用于iPad的应用程序(使用Titanium Appcelerator),用于录制和播放多个视频文件。此时,我可以无休止地录制视频,但当我播放它们时,应用程序会崩溃,看似随意。例如:播放视频A,然后播放视频B,然后播放C,然后返回A,应用程序在播放过程中崩溃回主屏幕。重新启动应用程序并执行完全相同的操作,它会很好,让我播放另外几个视频,然后当我回到视频列表时崩溃。崩溃日志通常以此开头:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x4650974c
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x33adbca4 0x33ad9000 + 11428
1   MediaPlayer                     0x354469d6 0x353d9000 + 448982
2   Foundation                      0x333dd7c6 0x3334d000 + 591814
3   CoreFoundation                  0x3712ea40 0x370b9000 + 481856
4   CoreFoundation                  0x37130ec4 0x370b9000 + 491204
5   CoreFoundation                  0x3713183e 0x370b9000 + 493630
6   CoreFoundation                  0x370c1ebc 0x370b9000 + 36540
7   CoreFoundation                  0x370c1dc4 0x370b9000 + 36292
8   GraphicsServices                0x36ffc418 0x36ff8000 + 17432
9   GraphicsServices                0x36ffc4c4 0x36ff8000 + 17604
10  UIKit                           0x35009d62 0x34fdb000 + 191842
11  UIKit                           0x35007800 0x34fdb000 + 182272
12  VideoRiver                      0x000042bc 0x1000 + 12988
13  VideoRiver                      0x00003b60 0x1000 + 11104
  • iOS SDK 4.3,
  • XCode 3.2.6,
  • Titanium SDK 1.7.1,
  • iPad 2,32GB 3G,
  • iPad iOS 4.3.3

1 个答案:

答案 0 :(得分:0)

我相信我找到了一个解决方法。到目前为止,在我的问题中概述的相同情况下没有崩溃。不同之处在于,我不是为视频创建单独的窗口,而是将视频播放器放在视图上,然后隐藏并根据需要显示它。以下是适用于Titanium Appcelerator的一些代码:

function Playback() {

    var self = this;
    this.activeMovie = null;
    this.baseView = null;

    this.create = function () {

        self.activeMovie = Ti.Media.createVideoPlayer({
            top: 0,
            left: 0,
            width: Ti.Platform.displayCaps.platformWidth,
            height: Ti.Platform.displayCaps.platformHeight,
            backgroundColor: '#111',
            movieControlStyle: Ti.Media.VIDEO_CONTROL_EMBEDDED,
            scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT
        });

        self.baseView = Ti.UI.createView({
            top: 0,
            left: 0,
            width: Ti.Platform.displayCaps.platformWidth,
            height: Ti.Platform.displayCaps.platformHeight
        });

        self.baseView.hide();

        self.doneBtn = Ti.UI.createButton({
            title: 'Done',
            color: '#fff',
            backgroundColor: 'blue',
            backgroundImage: 'none',
            bottom: '15%',
            width: 120,
            height: 40,
            font: {fontSize: 16,fontWeight: 'bold',fontFamily: 'Helvetica Neue'},
            borderRadius:5,
            borderWidth:1,
            borderColor:'#a6a6a6'
        });

        self.doneBtn.addEventListener('click', function () {
            self.hide();
        });

        self.activeMovie.addEventListener('playbackState', function (e) {
            //*** Hide the video window when done.  Comment out if you don't want to do this.
            if (e.playbackState == 0) {
                self.hide();
            }
        });

        self.baseView.add(self.activeMovie);
        self.baseView.add(self.doneBtn);

    };

    Playback.prototype.getView = function () {
        return self.baseView;
    };

    Playback.prototype.show = function (filename) {
        self.activeMovie.url = Titanium.Filesystem.applicationDataDirectory + '/' + filename;
        self.baseView.show();
        self.activeMovie.play();
    };

    Playback.prototype.hide = function () {
        self.baseView.hide();
        self.activeMovie.stop();
    };

    this.create();
}

要使用此功能,请执行以下操作:

var player = new Playback();
Titanium.UI.currentWindow.add(player.getView());
player.show("mymovie.mov");

享受!