SCLPlayer是SoundCloud HTML5小工具的基于UIWebView的包装器。它允许您轻松嵌入SoundCloud播放器,并从您的Cocoa代码中与应用它通信。
要创建播放器...
[[SCLPlayerViewController alloc] initWithURL:<<SoundCloud URL>> configuration:nil]
要控制播放器...
- (void)play;
- (void)playTrackWithID:(NSString*)soundcloudTrackID;
- (void)pause;
- (void)next;
- (void)prev;
- (void)seekTo:(NSUInteger)milliseconds;
- (void)setVolume:(NSUInteger)volume;
- (void)toggle;
要查询播放器...
- (void)getSounds:(SCLPlayerResponseHandler)responseBlock;
- (void)getCurrentSound:(SCLPlayerResponseHandler)responseBlock;
- (void)getCurrentSoundIndex:(SCLPlayerResponseHandler)responseBlock;
- (void)getVolume:(SCLPlayerResponseHandler)responseBlock;
- (void)getDuration:(SCLPlayerResponseHandler)responseBlock;
- (void)getPosition:(SCLPlayerResponseHandler)responseBlock;
您可以通过订阅事件来根据用户与播放器的交互更新您的UI。可用的通知有...
SCLPlayerDidLoadNotification
SCLPlayerDidPlayNotification
SCLPlayerDidPauseNotification
SCLPlayerDidFinishNotification
SCLPlayerDidSeekNotification
SCLPlayerPlayProgressNotification
SCLPlayerLoadProgressNotification
您还可以直接通过SCLPlayer的UIWebView直接消息HTML5播放器。插件对象可以通过SCLPlayer.scPlayer()
访问...
[sclPlayerInstance.webview stringByEvaluatingJavaScriptFromString:@"SCLPlayer.scPlayer().play()"];
要运行示例项目,克隆仓库,然后首先从示例目录运行pod install
。
SCLPlayer是为iOS 7及以上版本构建的。
Eric Robinson, eric DOT robinson AT me.com
SCLPlayer可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。