除了上述的的实现方式,库还提供,和 urce 。这些实现能够通过组合能够支持更复杂的功能 。下面对一些常见的用例进行说明 。注意,尽管下面的实例使用的视频 ,它们同样适用于仅有音频 ,事实上适用于所有支持的 media types 的。
- afile
给定的视频文件和一个单独的字幕文件,可以将它们合并到用于的单一来源 。
文章插图
MediaSource videoSource = new ExtractorMediaSource(videoUri, ...);MediaSource subtitleSource = new SingleSampleMediaSource(subtitleUri, ...);// Plays the video with the sideloaded subtitle.MergingMediaSource mergedSource =new MergingMediaSource(videoSource, subtitleSource);
a video
【Google Exoplayer 之全面认识】 可以实现视频的无缝循环 。下面演示了如何实现无缝循环 。也可以创建一个指定循环计数的。
MediaSource source = new ExtractorMediaSource(videoUri, ...);// Loops the video indefinitely.LoopingMediaSource loopingSource = new LoopingMediaSource(source);
aof
urce 使得支持顺序播放两个或多个单独的S,下面的示例顺序播放两段视频 。无缝切换资源,并且对被串联资源的格式是否相同没有要求 。
MediaSource firstSource = new ExtractorMediaSource(firstVideoUri, ...);MediaSource secondSource = new ExtractorMediaSource(secondVideoUri, ...);// Plays the first video, then the second video.ConcatenatingMediaSource concatenatedSource =new ConcatenatingMediaSource(firstSource, secondSource);
可以为了更不寻常的用例进一步结合复合。给定两个视频 A 和 B,下面的例子演示了如何使用和urce 按照( A,A,B)的序列进行无线循环 。
MediaSource firstSource = new ExtractorMediaSource(firstVideoUri, ...);MediaSource secondSource = new ExtractorMediaSource(secondVideoUri, ...);// Plays the first video twice.LoopingMediaSource firstSourceTwice = new LoopingMediaSource(firstSource, 2);// Plays the first video twice, then the second video.ConcatenatingMediaSource concatenatedSource =new ConcatenatingMediaSource(firstSourceTwice, secondSource);// Loops the sequence indefinitely.LoopingMediaSource compositeSource = new LoopingMediaSource(concatenatedSource);
下面的例子是等价的,这表明实现相同的结果方式不止一个 。
MediaSource firstSource = new ExtractorMediaSource(firstVideoUri, ...);MediaSource secondSource = new ExtractorMediaSource(secondVideoUri, ...);// Plays the first video twice, then the second video.ConcatenatingMediaSource concatenatedSource =new ConcatenatingMediaSource(firstSource, firstSource, secondSource);// Loops the sequence indefinitely.LoopingMediaSource compositeSource = new LoopingMediaSource(concatenatedSource);
避免在一次中用同一个实例多次,除非文档中明确允许 。在上面的例子中两次使用的就是这样的情况,由于对中 urce 明确规定,重复项是允许的 。在一般情况下,由组合物形成的对象的曲线应该是一个树 。在中使用多个等同于的实例是允许的 。
- 探秘关羽死后的封神之路:清朝最盛
- 007 【编程之路扫雷游戏】(C语言实现)
- 六 SPSSSPSS之回归分析衍生方法(图文+数据集)
- 允禩、允禟被诛:雍正与允禩允禟之间的兄弟惨祸
- 赔本买卖,弹丸之地也要争,元朝远征日本打的是什么主意?
- 揭秘秦始皇陵:沉睡地下的千古之谜
- 皇太极登基之谜努尔哈赤曾有意传位于多尔衮
- 宋之问曾邂逅神童骆宾王受其启发写就了名篇
- 垓下之战是怎样发生的?刘邦为什么要撕毁盟约
- 揭秘宋神宗赵顼:励精图治却将北宋送上灭亡之路