20

I'm playing a video on tvOS using the following code:

NSString *filePath = [[NSBundle mainBundle] pathForResource:name ofType:@"mov"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];

self.player = [AVPlayer playerWithURL:fileUrl];
AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];

avPlayerLayer.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height);
[view.layer addSublayer:avPlayerLayer];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(replayMovie:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];

[self.player play];

But I'm getting the following error

ERROR: >aqme> 718: MEMixerChannel::EnableProcessor: failed to open processor type 0x705f6571

Any ideas how to fix it?

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
Wojtek
  • 1,006
  • 11
  • 30

3 Answers3

24

Are you running the app in the simulator or on the Apple TV dev kit?

For tvOS, most AV related bugs/crashes I've encountered only occur when I'm using the Apple TV simulator - once I run the app on the physical device, they tend to disappear.

HGDev
  • 2,203
  • 2
  • 17
  • 23
  • Yeah, I'm running it on the simulator. I thought that it might be the case. Unfortunately I don't have Applet TV yet to test it. Thanks anyways. – Wojtek Oct 11 '15 at 14:19
  • @Wojtek Did you see my answer? I got the code working fine in the simulator. – ABeanSits Oct 16 '15 at 17:44
  • @ABeanSits Did you see my question? I posted code there, your answer is exactly the same code just in Swift... – Wojtek Oct 19 '15 at 08:20
4

I'm getting a video to load and play locally on the simulator. I wrote it in Swift but you should be able to translate it fairly easy.

    if let path = NSBundle.mainBundle().pathForResource("4", ofType:"mp4") {
        let url = NSURL(fileURLWithPath: path)
        let videoPlayer = AVPlayer(URL: url)
        let playerLayer = AVPlayerLayer(player: videoPlayer)
        playerLayer.frame = self.view.frame
        self.view.layer.addSublayer(playerLayer)
        videoPlayer.play()
    }

Make sure fileUrl is not nil and try removing code that is not needed (like the notification-part) so we can deduce which part is failing.

I'm using Xcode 7.1beta3.

ABeanSits
  • 1,725
  • 1
  • 17
  • 34
1

You don't want to subclass AVPlayerViewController. From the docs:

IMPORTANT

Do not subclass AVPlayerViewController. Overriding this class’s methods is unsupported and results in undefined behavior.

Instead, use a regular UIViewController, and then attach the AVPlayerViewController's view to it.

Using @AbeanSits's code (I'm using RubyMotion, but you can translate to Obj-C) worked. Here's my version:

  def viewDidAppear(_)
    super

    @player_controller = AVPlayerViewController.alloc.init
    @player_controller.player = AVPlayer.alloc.initWithURL(current_url)
    self.addChildViewController(@player_controller)
    self.view.addSubview(@player_controller.view)
    @player_controller.view.frame = self.view.frame
    @player_controller.player.play
  end
Jamon Holmgren
  • 23,738
  • 6
  • 59
  • 75