乐听项目分析(播放列表中的歌曲)

应用层调用播放器的方法例如点击列表播放:

1.首先取得当前的device 然后进行播放

LTDevice *device = [AppUtils getDeviceMonitor].getDeviceManager.getCurDevice;

if (device.player) {

if (self.playlist && startIndex < self.playlist.songs.count) {

[device.player playWithIndex:startIndex playlist:self.playlist];

}

}

播放歌曲的方法:

LTMediaPlayer中调用这个API播放;

1.- (void)playWithIndex:(NSInteger)index playlist:(LTPlaylist *)playlist

Kxmovie中调用下面这个API播放;

2.- (void)play:(LTSong *)song position:(CGFloat)position

这个API 根本上是根据Url ,所以内部要获取song的Url

 - (void)getCacheUrlWithSong:(LTSong *)song position:(CGFloat)position listener:(getCacheListener)listener;

本地的songUrl 是localUrl;

1.方法代码如下 主要根据不同情况做各种处理,但这些情况没有做具体说明;

- (void)playWithIndex:(NSInteger)index playlist:(LTPlaylist *)playlist {

if ([self ipIsValid] && playlist) {

//如果有手机正在播放,则需要提交到服务器

if (type == LOCAL && _playInfo.status == PLAYING && [_playInfo.progress longTimeValue] >= 5) {

[self subjectPlayInfo];

}

[self setPlaylist:[playlist copyObject]];

if (_playInfo.playlist && index >= 0 && index < [_playInfo.playlist.songs count]) {

_playInfo.index = index;

LTSong *song = [_playInfo.playlist.songs objectAtIndex:index];

if (song.from != FROM_LOCAL) {

if ([AppUtils getNetType] == DISCONNECTED) {

_playInfo.status = STOPPED;

return;

}

if (type == BOX && _playInfo.isOutdoorMode) {

[[LTOutdoorPlayHelper sharedInstance] buildServerPlaylist:_playInfo.playlist];

}

} else {

//如果是本地推送,则需要更换当前的歌曲列表

if (type == BOX) {

[[AppUtils getLocalMusicManager] changeSvrTracklist:_playInfo.playlist.songs listener:^(LTResult *result) {

_playInfo.pid = _playInfo.playlist.pid = [[AppUtils getLocalMusicManager] getSvrPlaylistId];

[self play:song playlistId:_playInfo.playlist.pid seek:@"00:00" index:0];

}];

return;

}

}

[self play:song playlistId:_playInfo.playlist.pid seek:@"00:00" index:index];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容