Passing AVPlayer to another ViewController with no video other than sound

I am trying to pass AVPlayer to one tableviewcell to another View controller. I tested this on a simulator and it works, but when I tested it on an iPhone I can only hear audio, not video. My goal is to reduce loading times by using the same player, not the movie url, as I get the video from the internet and put it in the AVPlayer.

VideoDetailsViewController.h

@property (nonatomic, retain) AVPlayer *player;
@property (nonatomic, retain) IBOutlet VPVideoPlayer *videoPlayer;

      

VideoDetailsViewController.m

-(id)initWithAVPlayer:(AVPlayer*)player
{
if(self = [super initWithNibName:@"VideoDetailsViewController" bundle:nil]) {
_player = player;
}

return self;
}

- (void)viewDidLoad {
[super viewDidLoad];    
[self.videoPlayer setPlayer:self.player];
}

      

Parts of VideoPlayer.m

-(id)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]) {

    }

return self;
}

+ (Class)layerClass
{
    return [AVPlayerLayer class];
}

- (AVPlayer*)player
{
    return [(AVPlayerLayer*)[self layer] player];
}

- (void)setPlayer:(AVPlayer*)player
{
    [(AVPlayerLayer*)[self layer] setPlayer:player];
}

      

thanks for the help

+3


source to share





All Articles