Search code examples
iosvimeo

iOS VIMVideoPlayerView can't load vimeo videos


I'm making an iOS app in Objective C which has to load video with vimeo urls. I wanted to use a video player and I used this : https://github.com/vimeo/VIMVideoPlayer. I follow the read me instructions, however I 'm not able to read vimeo videos, I got an error:

Video player Status Failed: error = Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo=0x7f9c5d17b8c0 {NSUnderlyingError=0x7f9c5d176910 "The operation couldn’t be completed. (OSStatus error -12847.)", NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open}

Here 's my code :

-(void)viewDidLoad
{
    [super viewDidLoad];

    self.videoPlayerView = [[VIMVideoPlayerView alloc] init];
    self.videoPlayerView.translatesAutoresizingMaskIntoConstraints = NO;
    self.videoPlayerView.delegate = self;
    [self.videoPlayerView setVideoFillMode:AVLayerVideoGravityResizeAspect];
    [self.videoPlayerView.player enableTimeUpdates];
    [self.videoPlayerView.player enableAirplay];
    [self.view addSubview:self.videoPlayerView];
    NSDictionary *views = NSDictionaryOfVariableBindings(_videoPlayerView);
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_videoPlayerView]-0-|" options:0   metrics:nil views:views]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_videoPlayerView]-0-|" options:0   metrics:nil views:views]];

    //this is the kind of url I want to load
    NSURL *URL = [NSURL URLWithString:@"https://player.vimeo.com/video/51806929"];
    [self.videoPlayerView.player setURL:URL];
    [self.videoPlayerView.player play];
}

Thanks for your help.


Solution

  • This is not a URL to a video file (https://player.vimeo.com/video/51806929), it's a URL to a webpage.

    URLs passed to the video player should be URLs to an actual video file resource.

    You can test VIMVideoPlayer out by dropping an mp4 file onto a server and passing that URL to the player.

    If you're a Vimeo PRO account user when you request the JSON for a specific video or list of videos from the Vimeo API, you'll see a list of VideoFile objects associated with each video object. These represent various resolution video files for this particular video. Each has a URL. You can pass this URL to the player.

    Let us know if you have questions!