我正在使用exoplayer已创建多Angular 的m3u8文件如何在android上切换Angular ?

mwecs4sa  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(284)

m3u8苍蝇


# EXTM3U

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="200kbs",NAME="Angle1",AUTOSELECT=YES,DEFAULT=YES

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="200kbs",NAME="Angle2",AUTOSELECT=YES,DEFAULT=NO, URI="Angle2/200kbs/prog_index.m3u8"

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="200kbs",NAME="Angle3",AUTOSELECT=YES,DEFAULT=NO, URI="Angle3/200kbs/prog_index.m3u8"

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="500kbs",NAME="Angle1",AUTOSELECT=YES,DEFAULT=YES

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="500kbs",NAME="Angle2",AUTOSELECT=YES,DEFAULT=NO, URI="Angle2/500kbs/prog_index.m3u8"

# EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="500kbs",NAME="Angle3",AUTOSELECT=YES,DEFAULT=NO, URI="Angle3/500kbs/prog_index.m3u8"

# EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",LANGUAGE="en",NAME="English",AUTOSELECT=YES, DEFAULT=YES,URI="eng/prog_index.m3u8"

# EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=300000,CODECS="mp4a.40.2,avc1.4d401e", VIDEO="200kbs",AUDIO="aac"

Angle1/200kbs/prog_index.m3u

# EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=754857,CODECS="mp4a.40.2,avc1.4d401e", VIDEO="500kbs",AUDIO="aac"

Angle1/500kbs/prog_index.m3u8

创建了一个类似于上述文件的文件。
活动

MediaItem mediaItem = new MediaItem.Builder()
                .setUri(getString(R.string.live_url))
                .setMimeType(MimeTypes.APPLICATION_M3U8)
                .build();
mainPlayer.setMediaItem(mediaItem);
mainPlayer.setPlayWhenReady(playWhenReady);
mainPlayer.seekTo(currentWindow, playbackPosition);
mainPlayer.prepare();

如果我应用的网址播放器工作良好。重写ontimelinechanged以打印日志。

Object manifest = mainPlayer.getCurrentManifest();
HlsManifest hlsManifest = (HlsManifest) manifest;
for(String arg : hlsManifest.masterPlaylist.tags){
    Log.d(TAG, "master tag : " + arg);
}
for(HlsMasterPlaylist.Rendition arg : hlsManifest.masterPlaylist.videos){
    Log.d(TAG, "rendition.url : " + arg.url);
    Log.d(TAG, "rendition.groupId : " + arg.groupId);
    Log.d(TAG, "rendition.name : " + arg.name);
}

日志打印

master tag : #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="BTS",NAME="Main",AUTOSELECT=YES,DEFAULT=YES
master tag : #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="BTS",NAME="RapMonster",AUTOSELECT=YES,DEFAULT=NO, URI="rapMonster/prog_index.m3u8"
master tag : #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="BTS",NAME="Suga",AUTOSELECT=YES,DEFAULT=NO, URI="suga/prog_index.m3u8"
master tag : #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="Main",AUTOSELECT=YES, DEFAULT=YES,URI="audio/prog_index.m3u8"
master tag : #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=754857,CODECS="mp4a.40.2,avc1.4d401e", VIDEO="BTS",AUDIO="aac"
rendition.url : http://custom_domain/resources/output/rapMonster/prog_index.m3u8
rendition.groupId : BTS
rendition.name : RapMonster
rendition.url : http://custom_domain/resources/output/suga/prog_index.m3u8
rendition.groupId : BTS
rendition.name : Suga

如何将主视频转换为同一组中的另一个命名视频?
setselectionoverride方法切换曲目,但不能播放同一组中的其他视频。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题