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 ledyba-z avatar mzeeshanid avatar zsk425 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  avatar  avatar  avatar  avatar  avatar  avatar

lmmediaplayer's Issues

ex_bad_access

error in delegate while switching between viewcontrolls

Player fails to replay file from a web URL

I have LMMediaPlayer added to a subview in my app.

The player only has one URL of a video file hosted on a webserver.

When I tap play, the player starts playing the file and eventually ends with a black screen.
Now when I tap play again, one of the following things can happen:

  • It takes a little time and then starts replaying the video.
  • It briefly flashes the start of the video and goes back to black screen, the slider stays the end. If I tap play again, then the slider shows that the video is playing but the screen remains black.

There is no Audio in the video files so I can not comment on whether I am getting audio during these scenarios or not.

I have this behavior on iOS 9.02 and the latest iOS, I have not checked on older versions of iOS, I also get this message in Xcode whenever the file does not replay: unable to load asset current status: 3 error: (null)

Landscape mode issue

画面回転に対応していない画面からフルスクリーンモードに遷移したあと、画面向きを変えてその状態からモードを元に戻すと画面レイアウトが崩れる

buffer concept

can you plz implement a buffer or some caching concept,
like if the user play one media, the next media is preparing the background,
and if the user reclick on the same media it wont downloading from the beginning,
this is important thank you

cocoapods

can you plz add cocoapods for it , ,
it will be much more famous
tx

Import "LMMediaPlayer" twice

c50262f

duplicate symbol OBJC_METACLASS$_LMMediaItemStreamingCache in:
/Users/zhaosk/Library/Developer/Xcode/DerivedData/LMMediaPlayer-dsdiqyvwyauqbidvycmhbqlfdgoz/Build/Intermediates/LMMediaPlayer.build/Debug-iphoneos/LMMediaPlayer.build/Objects-normal/armv7/LMMediaItemStreamingCache.o
/Users/zhaosk/Library/Developer/Xcode/DerivedData/LMMediaPlayer-dsdiqyvwyauqbidvycmhbqlfdgoz/Build/Products/Debug-iphoneos/libPods-LMMediaPlayer-LMMediaPlayer.a(LMMediaItemStreamingCache.o)
duplicate symbol OBJC_CLASS$_LMMediaItemStreamingCache in:
/Users/zhaosk/Library/Developer/Xcode/DerivedData/LMMediaPlayer-dsdiqyvwyauqbidvycmhbqlfdgoz/Build/Intermediates/LMMediaPlayer.build/Debug-iphoneos/LMMediaPlayer.build/Objects-normal/armv7/LMMediaItemStreamingCache.o
/Users/zhaosk/Library/Developer/Xcode/DerivedData/LMMediaPlayer-dsdiqyvwyauqbidvycmhbqlfdgoz/Build/Products/Debug-iphoneos/libPods-LMMediaPlayer-LMMediaPlayer.a(LMMediaItemStreamingCache.o)
ld: 2 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproduce steps:
1.clone the project;
2.cd Example,and pod install;
3.open LMMediaPlayer.xcworkspace/ and then build.

Slider

For short video at 00:00 the Slider indicate still time, see image.

thank you.
img_6862
img_6861

Sometimes not play video on ios7

Problem with ios7.

When i play video from streaming, log error print:

2015-02-03 18:36:52.257 vietapps[6287:60b] mediaPlayerViewWillChangeState state: 1
2015-02-03 18:37:02.260 vietapps[6287:4b0b] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

Sometimes it's play, sometimes it's not play.
ios8 play good but ios7 sometimes die :(

I'm try to debug but i cannot found the problem.

It's change to state 1 and die.

Could not load NIB in bundle

When trying to initialize plaerView

#import "LMMediaPlayer.h"
#import "LMMediaPlayerView.h"
//...
 LMMediaPlayerView *player = [LMMediaPlayerView sharedPlayerView];

i get:

'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/816AAFE4-40C8-42B0-BF7B-26608712A24E/MyApp.app> (loaded)' with name 'LMMediaPlayerView''
*** First throw call stack:
(0x1834cf100 0x18feac1fc 0x1834cf040 0x186852c40 0x1001483bc 0x100148320 0x190483fd4 0x190484e7c 0x1001482c0 0x10005c990 0x1001966bc 0x10019747c 0x10019460c 0x1001946d0 0x186492fe0 0x186084258 0x18607ee20 0x18607ecd8 0x18607e560 0x18607e304 0x186077c38 0x18348f858 0x18348cae0 0x18348ce6c 0x1833cddd0 0x18906dc0c 0x1864fefc4 0x100089218 0x19049faa0)
libc++abi.dylib: terminating with uncaught exception of type NSException

I have installed it via Pods.

Could not load NIB with name 'LMMediaPlayerView' in Swift project

I've installed LMMediaPlayer through CocoaPods in a swift project and on a ViewController I wrote this code (following README):

override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.

        var url = NSURL(string: "URL")

        let dict: [NSObject : AnyObject] = [
            LMMediaItemInfoURLKey        : url!,
            LMMediaItemInfoContentTypeKey : (1)
        ]

        player = LMMediaPlayerView.sharedPlayerView()
        item1 = LMMediaItem.init(info:dict)

        player.mediaPlayer.addMedia(item1)
        self.view.addSubview(player)
        player.mediaPlayer.play()

        super.viewDidLoad()
}

but the project is crashing with this message:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/092760CB-F3F0-458A-93AC-5F87506A8340/YTDraggableVideo.app> (loaded)' with name 'LMMediaPlayerView''

I'm having this problem using Xcode 7.3.1 and Deployment Target 9.3.

It's possible to playback captured videos and/or recorded sounds?

I'm recodring videos with UIImagePickerController and following your examples i'm doing this:

        NSURL *videoURL = [attachmentDict valueForKey:RESOURCE_KEY];
        //NSURL *videoURL = [NSURL URLWithString:[(NSURL *)[attachmentDict valueForKey:RESOURCE_KEY] path]];
        //Get shared player
        LMMediaPlayerView *player = [LMMediaPlayerView sharedPlayerView];

        //Create media item with URL.
        LMMediaItem *item1 = [[LMMediaItem alloc] initWithInfo:@{
                                                                 LMMediaItemInfoURLKey:videoURL,
                                                                 LMMediaItemInfoContentTypeKey:@(LMMediaItemContentTypeVideo)
                                                                 }];
        [player.mediaPlayer addMedia:item1];
        [player setFrame:preview.bounds];
        [preview addSubview:player];
        [player.mediaPlayer play];

And i'm getting the player VC, with all video control shown and touchable, but without video, 00:00 second and black screen.

As you can see, i'm testing with 2 URL's, one it's the one i'm getting from UIImagePickerController and the other it's a URL builded with the path of the previous cited URL.

Same problem with recorded audio in MP4 format.

play youtube video

please help how i can play a youtube video i remmber with the old version i can play using
HCYoutubeParser but how i can play it now

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.