Coder Social home page Coder Social logo

vimvideoplayer's Introduction

⚠️⚠️⚠️ This library has been deprecated and will be removed in the future. Use PlayerKit instead. ⚠️⚠️⚠️

VIMVideoPlayer

VIMVideoPlayer is a simple wrapper around the AVPlayer and AVPlayerLayer classes.

Setup

Add the VIMVideoPlayerView and VIMVideoPlayer classes to your project.

Do this by including this repo as a git submodule or by using cocoapods:

# Add this to your podfile
target 'MyTarget' do
   pod 'VIMVideoPlayer', {CURRENT_POD_VERSION}
end

Usage

Create a new VIMVideoPlayerView instance or set up an @IBOutlet:

@IBOutlet weak var videoPlayerView: VIMVideoPlayerView!

...

override func viewDidLoad()
{
    // Configure the player as needed
    self.videoPlayerView.player.looping = true
    self.videoPlayerView.player.disableAirplay()
    self.videoPlayerView.setVideoFillMode(AVLayerVideoGravityResizeAspectFill)
    
    self.videoPlayerView.delegate = self
}

Play a video:

// Using an NSURL

if let path = NSBundle.mainBundle().pathForResource("waterfall", ofType: "mp4")
{
    self.videoPlayerView.player.setURL(NSURL(fileURLWithPath: path))
}
else
{
    // Video file not found!
}

/* 
  Note: This must be a URL to an actual video resource (e.g. http://website.com/video.mp4 or .m3u8 etc.),
  It cannot be a URL to a web page (e.g. https://vimeo.com/67069182),
  See below for info on using VIMVideoPlayer to play Vimeo videos.
*/

// Using an AVPlayerItem

let playerItem: AVPlayerItem = ...
self.videoPlayerView.player.setPlayerItem(playerItem)
self.videoPlayerView.player.play()

// Or using an AVAsset

let asset: AVAsset = ...
self.videoPlayerView.player.setAsset(asset)
self.videoPlayerView.player.play()

Optionally implement the VIMVideoPlayerViewDelegate protocol methods:

protocol VIMVideoPlayerViewDelegate 
{    
    optional func videoPlayerViewIsReadyToPlayVideo(videoPlayerView: VIMVideoPlayerView!)
    optional func videoPlayerViewDidReachEnd(videoPlayerView: VIMVideoPlayerView!)
    optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, timeDidChange cmTime: CMTime)
    optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, loadedTimeRangeDidChange duration: Float)
    optional func videoPlayerViewPlaybackBufferEmpty(videoPlayerView: VIMVideoPlayerView!)
    optional func videoPlayerViewPlaybackLikelyToKeepUp(videoPlayerView: VIMVideoPlayerView!)
    optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, didFailWithError error: NSError!)
}

See VIMVideoPlayer.h for additional configuration options.

Playing Vimeo Videos

Vimeo Pro members can access playback URLs for Vimeo videos using the Vimeo API. Playback URLs are only included in the response object if the requesting account is a Vimeo Pro account.

If you have a Vimeo Pro account, when you make a request to the Vimeo API for a video object the response object will contain a list of video files. These represent the various resolution video files available for this particular video. Each has a link. You can use the string value keyed to link to create an NSURL. You can pass this NSURL to VIMVideoPlayer for playback.

Check out this Stack Overflow question for additional info.

You can use the Vimeo iOS SDK to interact with the Vimeo API.

For full documentation on the Vimeo API go here.

Found an Issue?

Please file it in the git issue tracker.

Want to Contribute?

If you'd like to contribute, please follow our guidelines found in CONTRIBUTING.md.

License

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

Questions?

Tweet at us here: @vimeoapi.

Post on Stackoverflow with the tag vimeo-ios.

Get in touch here.

Interested in working at Vimeo? We're hiring!

vimvideoplayer's People

Contributors

alfiehanssen avatar dtweston avatar edenvicary avatar efremidze avatar ghking avatar huebnerob avatar jmper1 avatar kevinzetterstrom avatar mikew-personal avatar nicolelehrer 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  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

vimvideoplayer's Issues

Storyboard Support

Doesn't seem to work with the storyboard. I'll try to fix it for storyboard support.

Play multi videos

Hi,
I have a list of vimeo, my flow is:
for vimeo in list {
fetch vimeo direct url
play vimeo with VIMVideoPlayer
}

I have a VIMVideoPlayer to reuse
But I don't known how to switch to other url? I try this, but not work:

  • (void)playVideoVimeo: (NSURL*)url {
    [_vimeoPlayerView.player setURL:url];
    [_vimeoPlayerView.player play];
    }

I tried to new 1 view for every video but I got other issue: the audio go first 2s after then is image. So with video about 2s, I don't see anything, only hear the sound.

I use
xcode 6.4
simulator 8.4

Thanks.

Cannot Open

Issue Summary

A brief but thorough description of the issue.
vimeoPlayer.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: self.videoPlayer.bounds.height) vimeoPlayer.delegate = self self.videoPlayer.addSubview(vimeoPlayer) vimeoPlayer.player.disableAirplay() if let url = URL(string: "https://player.vimeo.com/video/12765955") { vimeoPlayer.player.setURL(url) } vimeoPlayer.player.isLooping = false vimeoPlayer.setVideoFillMode(AVLayerVideoGravity.resizeAspectFill.rawValue) vimeoPlayer.player.player.play()

Above Code, I'm using to play Vimeo Video. When is ready to play I'm getting error Message

Video player Status Failed: player item error = Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x1c0856680 {Error Domain=NSOSStatusErrorDomain Code=-12847 "(null)"}}

I check with URL link on Browser is fine it's working on the browser. kindly do needfully

Reproduction Steps

Detailed steps to reproduce the issue.

Expected Behavior

What do you expect to happen as a result of the reproduction steps?

Actual Behavior

What currently happens as a result of the reproduction steps?

Example doesn't work

Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.```

Subclass that uses AVQueuePlayer

Hello,

I would like to add support for using AVQueuePlayer as the internal player. To do so, I am thinking of making changes that allow VIMVideoPlayer to be subclassed. I would then create a VIMQueueVideoPlayer class that subclasses VIMVideoPlayer. There are few approaches that I could take but I am thinking of doing the following:

  • Create a category called Subclassing
  • expose the readwrite AVPlayer *player property in this category
  • expose the setupPlayer instance method in this category
  • the VIMQueueVideoPlayer would then use this category to implement setupPlayer and set the player property with an instance of AVQueuePlayer.

Thoughts and feedback would be greatly appreciated before I make those changes.

Thanks!

Swift?

Is there a Swift version in the pipeline?

Unable to rotate the video

Issue Summary

I am trying to rotate the video if width of the video is greater than the height. Is that possible?

Stop linking to this library from Vimeo API docs

Issue Summary

The page https://developer.vimeo.com/api/libraries still references this repo but this repo states that it's deprecated.

Reproduction Steps

Visit https://developer.vimeo.com/api/libraries which links here. See that it is deprecated.

Expected Behavior

I expect https://developer.vimeo.com/api/libraries to point to the current recommended library.
https://github.com/vimeo/PlayerKit

Actual Behavior

Linked here instead of to https://github.com/vimeo/PlayerKit

Recommended usage in UITableView

What is the recommended usage for showing videos in UITableViews where multiple cells can have video shown in them? In my case, only one video should be playing at a given time. Is it better to associate a VIMVideoPlayer per cell or to have one VIMVideoPlayer associated with the UITableView that reset it's URL based on the UITableViewCell?

Play video with different source type

Hi,

I try to play video with different source type, but the second source can't be played.

First source type is mp4, and second source type is m3u8. It's work smoothly on iOS 9 device and simulator, but it can't work on iOS 7 & 8. How can I do?

Error Log:

didFailWithError: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x174467dc0 {NSUnderlyingError=0x17005eea0 "The operation couldn’t be completed. (OSStatus error -12783.)", NSLocalizedFailureReason=An unknown error occurred (-12783), NSLocalizedDescription=The operation could not be completed}

My code:

  • (void)setupVideoPlayer
    {
    self.videoPlayerView = [[VIMVideoPlayerView alloc] init];
    [self.videoPlayerView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.videoPlayerView setVideoFillMode:AVLayerVideoGravityResizeAspect];
    [self.videoPlayerView setDelegate:self];
    [self.videoPlayerView setBackgroundColor:[UIColor redColor]];
    [self.view insertSubview:self.videoPlayerView atIndex:0];

    NSURL *URL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"]; // https://secure-c.vimeocdn.com/p/video/yosemite_hd_ii_hd.mp4"];
    [self.videoPlayerView.player setDelegate:self];
    [self.videoPlayerView.player enableTimeUpdates];
    [self.videoPlayerView.player enableAirplay];
    [self.videoPlayerView.player setMuted:NO];
    [self.videoPlayerView.player setLooping:NO];
    [self.videoPlayerView.player setURL:URL];
    [self.videoPlayerView.player play];
    }

  • (void)changeSourceButtonClick
    {
    [self.videoPlayerView.player reset];
    [self.videoPlayerView.player setURL:[NSURL URLWithString:@"http://v.jxvdy.com/sendfile/w5bgP3A8JgiQQo5l0hvoNGE2H16WbN09X-ONHPq3P3C1BISgf7C-qVs6_c8oaw3zKScO78I--b0BGFBRxlpw13sf2e54QA"]];
    [self.videoPlayerView.player play];
    }

Thanks!

replaceCurrentItemWithPlayerItem:nil on dealloc - performance considerations

Issue Summary

replaceCurrentItemWithPlayerItem: on AVPlayer is an expensive operation. It is being called during player's deallocation. Skipping this method improves performance.

Reproduction Steps

To compare performance with and without calling replaceCurrentItemWithPlayerItem: with nil argument on dealloc just comment out that method. It is a part of resetPlayerItemIfNecessary.

Comments

I was not able to find evidence that removing player's item is necessary before deallocating the player, neither I found any bugs by skipping this step. The performance gain will be noticeable when using multiple players in UITableView / UICollectionView or reloading many players frequently (related to issue #39).

I may also assume, that this line of code was put in dealloc intentionally, so I would like to ask whether it can cause any bugs. If there is nothing wrong, I could submit a pull request.

Code

- (void)resetPlayerItemIfNecessary
{
    if (self.item)
    {
        [self removePlayerItemObservers:self.item];
        // I propose to skip following line during -dealloc
        [self.player replaceCurrentItemWithPlayerItem:nil];

        self.item = nil;
    }

    _volumeFadeDuration = DefaultVolumeFadeDuration;
    _playableBufferLength = DefaultPlayableBufferLength;

    _playing = NO;
    _isAtEndTime = NO;
    _scrubbing = NO;
}

Where I get URL to mp4

From docs it is unclear where I should get reference on MP4 file.
I don't want to use https://player.vimeo.com/video/<video_id>/config to get this information and have strong believe what there is more preferable and legal ay to get it.

How do I get path to MP4 which can be used with this player?

Best regards,
Sergey

Seek Vs Scrub

Issue Summary

Is there any documentation explaining the differences between seekToTime and scrub

Problem playing private video

I am trying to play a private video with VIMVideoPlayer and I am getting the following back trace after crash - the code is identical to the Saga example app. It even crashes with the saga video link - https://secure-c.vimeocdn.com/p/video/yosemite_hd_ii_hd.mp4. The Saga app plays my private video link.

Any idea why this is happening? I'm thinking there is something off in the setup of libraries. I don't see any libraries set up for Saga like AVFoundation.

(* thread #1: tid = 0x7c7e3, 0x0000000108685519 libc++abi.dylib__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 frame #0: 0x0000000108685519 libc++abi.dylibcxa_throw
frame #1: 0x00000001234e3755 AudioCodecsACBaseCodec::GetPropertyInfo(unsigned int, unsigned int&, unsigned char&) + 521 frame #2: 0x000000012358a69a AudioCodecsGetPropertyInfo(void_, unsigned int, unsigned int_, unsigned char_) + 38
frame #3: 0x0000000106fda751 AudioToolboxCodecConverter::CheckInitialize(void const_, unsigned int) + 433 frame #4: 0x0000000106fda3fa AudioToolboxCodecConverter::CodecConverter(OpaqueAudioComponent
&, OpaqueAudioComponentInstance
, StreamDescPair const&, StreamDescPair const&, bool, AudioConverterPrimeInfo const&) + 618
frame #5: 0x0000000106fdf6a3 AudioToolboxCodecDecoderFactory::BuildCodecConverterChain(StreamDescPair const&, ChainBuildSettings const&, AudioConverterChain_, PCMConverterFactory_) + 275 frame #6: 0x0000000106fc6b90 AudioToolboxConverterRegistry::CreateConverter(StreamDescPair const&, AudioConverterChain**, unsigned int, AudioClassDescription const*) + 272
frame #7: 0x0000000106fb5ae4 AudioToolbox_AudioConverterNewInternal + 340 frame #8: 0x000000010700ba7a AudioToolboxAudioQueueObject::AudioQueueObject(bool, bool, AudioStreamBasicDescription const&, unsigned int, AQRemoteClient&, AudioQueueOwner*, audit_token_t, unsigned int, int&) + 2314
frame #9: 0x000000010700c35a AudioToolboxAudioQueueObject::AudioQueueObject(bool, bool, AudioStreamBasicDescription const&, unsigned int, AQRemoteClient&, AudioQueueOwner_, audit_token_t, unsigned int, int&) + 74 frame #10: 0x000000010703ce98 AudioToolboxAQServer_NewQueue + 440
frame #11: 0x0000000107047d15 AudioToolboxAudioQueueNew(bool, AudioStreamBasicDescription const_, TCACallback<void*, void*> const&, CACallbackTarget const&, unsigned int, unsigned int, OpaqueAudioQueue**) + 373 frame #12: 0x0000000107047b91 AudioToolboxAudioQueueNewOutput + 81
frame #13: 0x0000000110a17ee9 MediaToolboxFigAudioQueueTimingShimNewOutput + 35 frame #14: 0x00000001108fa615 MediaToolboxsubaq_createSubAudioQueue + 637
frame #15: 0x00000001108fa0e4 MediaToolboxFigAudioQueueCreate + 752 frame #16: 0x00000001109a6306 MediaToolboxFigAudioQueueRenderPipelineCreate + 630
frame #17: 0x000000011095f4ab MediaToolboxfp_buildAudioRenderPipelineForTrack + 894 frame #18: 0x00000001109588cb MediaToolboxitemfig_rebuildRenderPipelinesAndBoss + 3269
frame #19: 0x0000000110957663 MediaToolboxplayerfig_prepareWorkingItem2 + 151 frame #20: 0x000000011094f8a6 MediaToolboxplayerfig_prepareWorkingItem + 91
frame #21: 0x000000011096467f MediaToolboxitemfig_assetPropertyBatchLoaded_prepareWorkingItem_internal + 137 frame #22: 0x00000001109645e8 MediaToolboxitemfig_assetPropertyBatchLoaded_prepareWorkingItem + 20
frame #23: 0x000000010847c920 CoreMediafigDeferredNotificationRun + 43 frame #24: 0x0000000107ffe174 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION** + 20
frame #25: 0x0000000107ffdd35 CoreFoundation__CFRunLoopDoTimer + 1045 frame #26: 0x0000000107fbfd3d CoreFoundation__CFRunLoopRun + 1901
frame #27: 0x0000000107fbf366 CoreFoundationCFRunLoopRunSpecific + 470 frame #28: 0x000000010a5f1a3e GraphicsServicesGSEventRunModal + 161
frame #29: 0x0000000104bb5900 UIKit`UIApplicationMain + 1282

  • frame #30: 0x0000000102b7596f BarBookmain(argc=1, argv=0x00007fff5d09f488) + 111 at main.m:15 frame #31: 0x00000001087ef145 libdyld.dylibstart + 1
    frame #32: 0x00000001087ef145 libdyld.dylib`start + 1

Question: Audio Selection

Hi, I want to add audio selection in the player without modifying your code.
What would be the clean way to approach this.

PS: I know how to change the audio via selectMediaOption. I just want to know how you guys would approach this. Would you place the code in the ViewController, in the delegate videoPlayerViewIsReadyToPlayVideo? or is there a cleaner approach?

PPS: I don't have deliverables, I'm just trying to learn how to make simple and clean code. And I like your approach.

AVPlayerItemStatusUnknown after several player.reset() and player.setUrl()

Issue Summary

A brief but thorough description of the issue.

Reproduction Steps

repeat the following code several times

playerView.player.reset()
self.playerView.player.setURL(#validUrl)
playerView.player.play()

Expected Behavior

after setURL player status becomes AVPlayerItemStatusReadyToPlay regardless of repetition

Actual Behavior

player status permanently becomes AVPlayerItemStatusUnknown and will not recover with reset

Scrub and seek should be smooth

Issue Summary

A brief but thorough description of the issue.

Reproduction Steps

Detailed steps to reproduce the issue.

Expected Behavior

What do you expect to happen as a result of the reproduction steps?

Actual Behavior

What currently happens as a result of the reproduction steps?

No sound

hi, when I use your player play the movies ,the player no sound,why?

Not looping

I checked that the default value of looping is YES,
However, it doesn't loop when it finished running.
But if I set a breakpoint there and debug, it restart and playing again, and if I stop debug, it stop looping again.

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.