Giter Site home page Giter Site logo

lmmediaplayer's Introduction

LMMediaPlayer

[![CI Status](http://img.shields.io/travis/Akira Matsuda/LMMediaPlayer.svg?style=flat)](https://travis-ci.org/Akira Matsuda/LMMediaPlayer) Version License Platform

LMMediaPlayer is a video and an audio player for iPhone with replaceable user interface.

Requirements

  • Runs on iOS 6.0 or later.

Contribution

Please use clang-format and use .clang-format file which is containing this repo.

Installation

LMMediaPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LMMediaPlayer"

Usage

You can play MPMediaItem and http streaming contents with fullscreen or non-fullscreen mode.

//Get shared player
LMMediaPlayerView *player = [LMMediaPlayerView sharedPlayerView];

//Create media item with URL.
LMMediaItem *item1 = [[LMMediaItem alloc] initWithInfo:@{
	LMMediaItemInfoURLKey:[NSURL URLWithString:@"video or audio url"],
	LMMediaItemInfoContentTypeKey:@(LMMediaItemContentTypeVideo)
}];

//Create media item with MPMediaItem.
MPMediaItem *mediaItem =
LMMediaItem *item2 = [[LMMediaItem alloc] initWithMetaMedia:mediaItem contentType:LMMediaItemContentTypeVideo];

//Add queue.
[player.mediaPlayer addMedia:item1];
[player.mediaPlayer addMedia:item2];

//Play it!
[player.mediaPlayer play];

without player view.

//Get shared player
LMMediaPlayer *player = [LMMediaPlayer sharedPlayer];

//Create media item with URL.
LMMediaItem *item1 = [[LMMediaItem alloc] initWithInfo:@{
	LMMediaItemInfoURLKey:[NSURL URLWithString:@"video or audio url"],
	LMMediaItemInfoContentTypeKey:@(LMMediaItemContentTypeVideo)
}];

//Create media item with MPMediaItem.
MPMediaItem *mediaItem =
LMMediaItem *item2 = [[LMMediaItem alloc] initWithMetaMedia:mediaItem contentType:LMMediaItemContentTypeVideo];

//Add queue.
[player addMedia:item1];
[player addMedia:item2];

//Play it!
[player play];

Already implemented repeat mode and shuffle mode.

LMMediaPlayerView *player = [LMMediaPlayerView sharedPlayerView];
player.mediaPlayer.repeatMode = LMMediaRepeatModeNone;
player.mediaPlayer.repeatMode = LMMediaRepeatModeAll;
player.mediaPlayer.repeatMode = LMMediaRepeatModeOne;

[player.mediaPlayer setShuffleEnabled:YES];

To change user interface, use setButtonImages: and set images with these keys.

Keys
LMMediaPlayerViewPlayButtonImageKey
LMMediaPlayerViewPlayButtonSelectedImageKey
LMMediaPlayerViewStopButtonImageKey
LMMediaPlayerViewStopButtonSelectedImageKey
LMMediaPlayerViewFullscreenButtonImageKey
LMMediaPlayerViewFullscreenButtonSelectedImageKey
LMMediaPlayerViewUnfullscreenButtonImageKey
LMMediaPlayerViewUnfullscreenButtonSelectedImageKey
LMMediaPlayerViewShuffleButtonShuffledImageKey
LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey
LMMediaPlayerViewShuffleButtonUnshuffledImageKey
LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey
LMMediaPlayerViewRepeatButtonRepeatOneImageKey
LMMediaPlayerViewRepeatButtonRepeatOneSelectedImageKey
LMMediaPlayerViewRepeatButtonRepeatAllImageKey
LMMediaPlayerViewRepeatButtonRepeatAllSelectedImageKey
LMMediaPlayerViewRepeatButtonRepeatNoneImageKey
LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey
LMMediaPlayerViewActionButtonImageKey

To show action button, set image with LMMediaPlayerViewActionButtonImageKey.

Use the following helper method for customising the progress bar:

[[LMMediaPlayerView sharedPlayerView] setProgressBarBorderColor:[UIColor whiteColor]
                                                    backgroundColor:[UIColor clearColor]
                                                          fillColor:[UIColor lightGrayColor]
                                                      minTrackColor:[UIColor redColor]
                                                     thumbTintColor:[UIColor whiteColor]];

Use the following helper method for customising the progress bar thumb:

[[LMMediaPlayerView sharedPlayerView] setProgressBarThumbImage:[UIImage imageNamed:@"thumb"]];

Of course, you can play video or audio in background mode and can control with control center. If you want to play with fullscreen mode, please add "View controller-based status bar appearance" key and set value with "NO" at your Info.plist

Author

Akira Matsuda, [email protected]

License

LMMediaPlayer is available under the MIT license. See the LICENSE file for more info.

lmmediaplayer's People

Contributors

0x0c avatar mzeeshanid avatar zsk425 avatar

Watchers

 avatar  avatar

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.