AVPlayer error while playing on tvOS
Asked Answered
M

3

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?

Morell answered 29/9, 2015 at 12:56 Comment(0)
H
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.

Hemphill answered 9/10, 2015 at 23:23 Comment(3)
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.Morell
@Morell Did you see my answer? I got the code working fine in the simulator.Saipan
@Saipan Did you see my question? I posted code there, your answer is exactly the same code just in Swift...Morell
S
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.

Saipan answered 13/10, 2015 at 23:7 Comment(0)
P
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
Pardon answered 15/10, 2015 at 17:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.