Code Monkey home page Code Monkey logo

srvideoplayer's Introduction

SRVideoPlayer

Custom interface video player which has various interactive gestures.

image

Features

  • Support to tap and drag bottom slider seek play progress.
  • Support to slide left half of the screen up or down to adjust brightness.
  • Support to slide right half of the screen up or down to adjust sound.
  • Support to slide the screen left or right to seek play progress.
  • Support to download network video so next time play directly with cached data.

Installation

CocoaPods

Add pod 'SRVideoPlayer' to the Podfile, then run pod install in the terminal.

Manual

Drag the SRVideoPlayer folder to the project.(Note: If the project has already import Masonry, you should remove it which in the SRVideoPlayer folder.)

APIs

/**
 Creates and returns a video player with video's URL, playerView and playerSuperView.

 @param videoURL        The URL of the video.
 @param playerView      The view which you want to display the video.
 @param playerSuperView The playerView's super view.
 @return A newly video player.
 */
+ (instancetype)playerWithVideoURL:(NSURL *)videoURL playerView:(UIView *)playerView playerSuperView:(UIView *)playerSuperView;

- (void)play;
- (void)pause;
- (void)resume;

- (void)destroyPlayer;

Usage

UIView *playerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width)];
playerView.center = self.view.center;
[self.view addSubview:playerView];
_videoPlayer = [SRVideoPlayer playerWithVideoURL:_videoURL playerView:playerView playerSuperView:playerView.superview];
_videoPlayer.videoName = @"Here Is The Video Name";
_videoPlayer.playerEndAction = SRVideoPlayerEndActionLoop;
[_videoPlayer play];

Custom

/**
 The action when the video play to end, default is SRVideoPlayerEndActionStop.
 */
@property (nonatomic, assign) SRVideoPlayerEndAction playerEndAction;

/**
 The name of the video which will be displayed in the top center.
 */
@property (nonatomic, copy) NSString *videoName;

Contacts

Submit an issue or email me if you have any questions. [email protected]

srvideoplayer's People

Contributors

guowilling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

srvideoplayer's Issues

Use SRVideoPlayer in collectionView's cell

It gives me following error -

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <SRVideoPlayerLayerView: 0x7fa64dc59640; frame = (0 0; 0 0); layer = <AVPlayerLayer: 0x600001fe7280>>: A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs.'

What i Did -

  • Took a view in xib of cell and made an outlet
  • In cell for row at index path method -
    SRVideoPlayer *videoPlayer = [SRVideoPlayer playerWithVideoURL:[NSURL URLWithString:dict[@"video"]] playerView:cell.vVideoPlayer playerSuperView:cell.contentView.superview];
    videoPlayer.videoName = @"Here Is The Video Name";
    videoPlayer.playerEndAction = SRVideoPlayerEndActionLoop;
    [videoPlayer play];

HOW CAN I USE IT??

Crash on ios 12

I am having crash on iOS 12 within bottom method. I guess the video is not coming correctly.

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

Mute the player

_player.muted = YES;

This code for mute the player is not working.
How can we mute player ?

can you please add these feature.

  • add next and previous button
    -delegate to handel video has completed
  • delegate to track video time(ie how much video has played and all)
  • add custom view to this player view.

How can i implement this player in UITableViewCells?

I have implemented player in UITableViewCells. Its not working properly as it has to. When cell is reuse i need its state as its previously has. When i reload the tableview the video layer of one cell is copied to another cells video layer.
Below is the screen when tableview is not reloaded yet.

simulator screen shot 15-feb-2017 3 10 03 pm

After reload i insert some records (objects) in tableview and reload. The UI is disturbed and SRVideoPlayer's objects are misplaced.
simulator screen shot 15-feb-2017 3 11 04 pm

TableViewCell are XIB's

Code in VideoCell.h
@property (nonatomic, strong) SRVideoPlayer *videoPlayer;

Code in ViewController cellForRowAtIndexPath

if (cell.videoPlayer == nil) {
                    cell.videoPlayer = [SRVideoPlayer playerWithVideoURL:[NSURL URLWithString:videoUrl] playerView:cell.viewVideoLayer playerSuperView:cell.viewVideoLayer.superview];
                    cell.videoPlayer.videoName = [[arrData objectAtIndex:indexPath.row] objectForKey:MessageUserFullName];
                    cell.videoPlayer.playerEndAction = SRVideoPlayerEndActionLoop;
                    [cell.videoPlayer play];
                    [cell.vwContents bringSubviewToFront:cell.viewVideoLayer];
}

If I'm going wrong anywhere please update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.