iOS Video player Vkvideoplayer

Source: Internet
Author: User

Vkvideoplayer is a video player used in the Viki IOS app.

Key Features:

Fully customizable UI
Any size or even fullscreen
Support subtitle Display
Customizable subtitle display style
Support for HTTP live streaming
Support for screen orientation adjustment
Bulletproof event machine to easily integrate features like video ads
Lots of delegate callbacks for your own logging requirements
Vkvideoplayer is a rigorously tested Viki video player and is a simple plugin that can handle all the technical details of video playback. By default, the library plays video on Vkvideoplayerview using the Avplayer and Avplayeritem classes. It is achieved by entering a tracking object that implements the Vkvideoplayertrackprotocol protocol. The default video player creates avplayer and Avplayeritem objects to play the video.

has some improvements: fully customizable UI, no full-screen limit (can be set any size), can display subtitles (support SRT) and customizable, support HTTP Live streaming protocol, support direction change, even if the direction of the lock, support bulletproof event mechanism, Features such as video ads can be easily integrated, and delegate callbacks can be used for log requirements.

iOS Video player Vkvideoplayer

Vkvideoplayer Usage Tutorials

Play live stream

Vkvideoplayerviewcontroller *viewcontroller = [[Vkvideoplayerviewcontroller alloc] init];
[Self Presentmodalviewcontroller:viewcontroller animated:yes];
[Viewcontroller playvideowithstreamurl:[nsurl urlwithstring:@ "http://content.viki.com/test_ios/ios_240.m3u8"];
Common methods

Self.player = [[Vkvikivideoplayer alloc] Initwithvideoplayerview:[[vkvikivideoplayer alloc] init]];
Self.player.delegate = self;
[Self.view AddSubview:self.player]

Vkvideoplayerview has an easy way to add to the view.

    • (void) Addsubviewforcontrol: (UIView *) view;
    • (void) Addsubviewforcontrol: (UIView ) View Toview: (UIView) Parentview;
    • (void) Addsubviewforcontrol: (UIView ) View Toview: (UIView) Parentview fororientation: ( Uiinterfaceorientationmask) orientation;

Display button
[Self.player.view Addsubviewforcontrol:newbutton ToView:self.player.view fororientation: Uiinterfaceorientationmasklandscape];

The properties of the Vkvideoplayer.

This attribute can change the behavioral orientation. If Uiviewcontroller only portrait mode, set it to Yes to rotate the screen.
@property (nonatomic, assign) BOOL forcerotate;

When you rotate the playback screen, the video player view will be this size.
@property (nonatomic, assign) CGRect landscapeframe;
Used when rotate to Landscape by Forcerotate. Video player View would be the this frame size.

About letters

There are a few ways to customize subtitles. Change the font size and use vksharedutility. Has a value of 3.
Value accepts @0, @1, @2 or @3;
@0:tiny
@1:medium
@2:large
@3:huge
[Vksharedutility setvalue:@1 Forkey:kvksettingssubtitlesizekey];

Or you can override the following method to customize the heading style.

    • (dtcssstylesheet*) Captionstylesheet: (nsstring*) Color {
      float fontSize = 1.3f;
      float shadowsize = 1.0f;

switch ([[[Vksharedutility Setting:kvksettingssubtitlesizekey] integervalue]) {
Case 1:
FontSize = 1.5f;
Break
Case 2:
FontSize = 2.0f;
Shadowsize = 1.2f;
Break
Case 3:
FontSize = 3.5f;
Shadowsize = 1.5f;
Break
}

dtcssstylesheet* stylesheet = [[Dtcssstylesheet alloc] initwithstyleblock:[nsstring stringwithformat:@ "body{\
Text-align:center;\
Font-size:%fem;\
Font-family:helvetica neue;\
Font-weight:bold;\
Color:%@;\
Text-shadow:-%fpx-%fpx%fpx #000,%fpx-%fpx%fpx #000,-%fpx%fpx%fpx #000,%fpx%fpx%fpx #000;
Vertical-align:bottom;\
} ", FontSize, Color, shadowsize, Shadowsize, Shadowsize, Shadowsize, Shadowsize, Shadowsize, Shadowsize, Shadowsize, shad Owsize, Shadowsize, Shadowsize, shadowsize];
return stylesheet;
}
Proxy method

Vkvideoplayer has entrusted agreement vkvideoplayerdelegate. You can use it for logging or other controls for your application.

This method is called before changing the state. If you haven't, you can prevent the video player from changing in status.
-(BOOL) Shouldvideoplayer: (vkvideoplayer*) Videoplayer Changestateto: (vkvideoplayerstate) tostate;

This method is before changing the state.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer Willchangestateto: (vkvideoplayerstate) tostate;

This method is called changing the state.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didchangestatefrom: (vkvideoplayerstate) fromstate;

This method is called before the video is loaded. If the video should not play, you can block it before traffic flows.
-(BOOL) Shouldvideoplayer: (vkvideoplayer*) Videoplayer Startvideo: (ID) track;

This method is called before the video is started. You can't stop the video here.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer Willstartvideo: (ID) track;

This method is called after the video is started.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer Didstartvideo: (ID) track;

This method is called every second while the video is playing.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didplayframe: (ID) Track time: (Nstimeinterval) Time Lasttime: ( Nstimeinterval) Lasttime;

This method is called finished playing the video. You can start playing the next video here.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didplaytoend: (ID) track;

This method is called when the user does some action.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didcontrolbyevent: (vkvideoplayercontrolevent) event;

This method is called when the user changes the bottom header language.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didchangesubtitlefrom: (nsstring*) Fronlang to: (nsstring*) ToLang;

This method is called before rotating the animation.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer Willchangeorientationto: (uiinterfaceorientation) orientation;

This method is called after rotating the animation.
-(void) Videoplayer: (vkvideoplayer*) Videoplayer didchangeorientationfrom: (uiinterfaceorientation) orientation;

An error occurred while calling this method.
-(void) Handleerrorcode: (Vkvideoplayererrorcode) ErrorCode track: (ID) track custommessage: (nsstring*) custommessage;

Code

This article by 51ios Original, reprint please indicate reprint from http://www.51ios.net/thirdlibs/5692.html

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS Video player Vkvideoplayer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.