AVFoundation 拍片专用

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

2016-11-25  本文已影响3人  IceWall_Rin

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

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];

}

上一篇下一篇

猜你喜欢

热点阅读