LLVideoPlayer 1.2.6

LLVideoPlayer 1.2.6

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2019年2月

huangguiyang维护。



  • mario

LLVideoPlayer

Version License Platform

基于AVPlayer的低级别视频播放器,支持缓存和预加载。

  • 简单且灵活
  • 缓存支持
  • 预加载支持
  • 内存映射IO

示例

要运行示例项目,请克隆仓库,并首先在示例目录中运行pod install

// create
self.player = [[LLVideoPlayer alloc] init];
[self.view addSubview:self.player.view];
self.player.view.frame = CGRectMake(10, 80, 300, 200);
self.player.delegate = self;


// load
NSURL *url = [NSURL URLWithString:@"<your stream url>"];  
[self.player loadVideoWithStreamURL:url];


// pause
[self.player pauseContent];

// play
[self.player playContent];

// dismiss
[self.player dismissContent];

// delegate
// see the header file for details.

代理

有一些您可能感兴趣的代理方法

// The first frame of the video is ready to display.
- (void)videoPlayer:(LLVideoPlayer *)videoPlayer readyForDisplay:(BOOL)readyForDisplay;

// The duration is available.
- (void)videoPlayer:(LLVideoPlayer *)videoPlayer durationDidLoad:(NSNumber *)duration;

// The buffer is empty or not.
- (void)videoPlayer:(LLVideoPlayer *)videoPlayer playbackBufferEmpty:(BOOL)bufferEmpty;

// The video is likely to keepup or not.
- (void)videoPlayer:(LLVideoPlayer *)videoPlayer playbackLikelyToKeepUp:(BOOL)likelyToKeepUp;

// The playback is stalled.
- (void)videoPlayerPlaybackStalled:(LLVideoPlayer *)videoPlayer;

/// more...

LLVideoPlayerDelegate以获取更多信息。

自定义UI控件

LLVideoPlayer不包含任何UI控件,以提供灵活性。您可以将自定义控件添加到容器视图LLVideoPlayerView中。

缓存支持

LLVideoPlayer 支持自定义缓存策略。要启用缓存支持(默认为禁用)

player.cacheSupportEnabled = YES;	// That's all, so simple...

设置自定义缓存策略

LLVideoPlayerCachePolicy *policy = [LLVideoPlayerCachePolicy new];
policy.diskCapacity = 500ULL << 20;	// max disk capacity in bytes, for example 500MiB
policy.outdatedHours = 7 *24;		// outdated hours, for example 7 days

player.cachePolicy = policy;

详情请参见 LLVideoPlayerCachePolicy

手动清除缓存

[LLVideoPlayer clearAllCache];

预加载支持

// start a preload request
[LLVideoPlayer preloadWithURL:url];

// start a preload request with specified bytes
[LLVideoPlayer preloadWithURL:url bytes:(1 << 20)];

// cancel a preload request
[LLVideoPlayer cancelPreloadWithURL:url];

// cancel all preload requests
[LLVideoPlayer cancelAllPreloads];

要求

iOS 7 或更高版本

安装

LLVideoPlayer 通过 CocoaPods 提供。要安装它,只需在 Podfile 中添加以下行:

pod "LLVideoPlayer"

作者

mario, [email protected]

许可证

LLVideoPlayer 在 MIT 许可证下可用。有关更多信息,请参见 LICENSE 文件。