Is iPad 2 video subsystem unstable?

0

I'm developing an app for iPad (using Titanium Appcelerator) that is designed to record and plays back multiple video files. At this point, I can record videos endlessly but when I to play them back, the app will crash, seemingly at random. For example: play video A, then video B, then C, then go back to A and the app crashes back to the home screen while in the middle of playback. Re-start the app and do the exact same thing, and it will be fine, and let me play another couple of videos, then crash when I go back to the list of videos. The crash logs often start with this:

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
ios
ipad
video
asked on Stack Overflow Jul 19, 2011 by mpemburn • edited Jul 19, 2011 by p.campbell

1 Answer

0

I believe I've found a workaround. So far, no crashes under the same circumstances outlined in my question. The difference is that rather than creating a separate window for the video, I am putting the video player on a view, then hiding and showing it as needed. Here's some code for Titanium Appcelerator that works:

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();
}

To use this, do the following:

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

Enjoy!

answered on Stack Overflow Jul 21, 2011 by mpemburn

User contributions licensed under CC BY-SA 3.0