TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Easy remote video playback in a UIView
subclass.
This is still in early stages of development, so proceed with caution when using this in a production application. Any bug reports, feature requests, or general feedback at this point would be greatly appreciated.
Build and run the CVUMoviePlayerViewExample
project in Xcode to see CVUMoviePlayerView
in action.
CVUMoviePlayerView
requires the MediaPlayer
Framework, so the first thing you'll need to do is include the framework into your project. In Xcode 4, go to the project file at the root of your workspace and select your active target. There should be several sections across the top of that window; choose "Build Phases". Next, click "Link Binary With Libraries" to expand that section to see the frameworks currently included in your project. Click the "+" at the bottom left and select "MediaPlayer.framework".
Now that the framework has been linked, all you need to do is drop CVUMoviePlayerView.{h,m}
into your project, and add #include "CVUMoviePlayerView.h"
to the top of classes that will use it.
Add an instance of CVUMoviePlayerView to the view of your choosing. Provide a videoURL and a frame. The view will show a play UIButton over a placeholder UIImageView that triggers the playback.
CGRect frame = CGRectMake(0, 0, 300, 300);
NSURL* videoURL = [NSURL URLWithString:@"https://devimages.apple.com.edgekey.net/resources/http-streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"];
CVUMoviePlayerView* moviePlayerView = [[CVUMoviePlayerView alloc] initWithFrame:frame videoURL:videoURL];
[self.view addSubview:moviePlayerView];
You can provide a placeholder image upon initialization.
CGRect frame = CGRectMake(0, 0, 300, 300);
UIImage* placeholderImage = [UIImage imageNamed:@"video_placeholder_image.png"];
NSURL* videoURL = [NSURL URLWithString:@"https://devimages.apple.com.edgekey.net/resources/http-streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"];
CVUMoviePlayerView* moviePlayerView = [[CVUMoviePlayerView alloc] initWithFrame:frame placeholderImage:placeholderImage videoURL:videoURL];
You can set an image for the play button.
// self.moviePlayerView is an already initialized instance of CVUMoviePlayerView
UIImage* playVideoButtonPlaceholderImage = [UIImage imageNamed:@"play_button.png"];
[self.moviePlayerView.placeholderPlayVideoButton setImage:playVideoButtonPlaceholderImage forState:UIControlStateNormal];
Claudiu-Vlad Ursache
CVUMoviePlayerView is available under the MIT license. See the LICENSE file for more info.