使用Android Exoplayer调整Dash流的音量 [英] Adjust Dash stream volume with Android Exoplayer

查看:559
本文介绍了使用Android Exoplayer调整Dash流的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图设置一个搜索栏来控制exoplayer流破折号实例的级别.

I'm trying to set up a seekbar to control the level of an instance of exoplayer streaming dash.

我正在使用的设置是演示项目的修改版本,无法确定我应该尝试影响搜寻栏输出的元素,即如何正确使用MSG_SET_VOLUME等 任何输入将不胜感激.

The setup I am using is a modified version of the demo project and am having trouble figuring out which element I should be trying to affect with the seekbars output ie how to use MSG_SET_VOLUME properly etc etc Any input would be massively appreciated.

我要寻找的最终结果是一个带有两个exoplayer实例的应用程序,它们都通过带有控制两个播放器混合的推子(seekbar)来传输破折号内容(一旦确定了这一点,我想如果数学是正确的) 再次感谢所有帮助,我到目前为止与Exoplayer在一起还算是新手!谢谢大家!

The end result I am looking for is an application with two instances of exoplayer both streaming dash content with a fader(seekbar) controlling the mix of the two players (which once this is figured out i presume should be easy enough if the maths is correct) Again any help would be massively appreciated I have had a bit of a time with Exoplayer so far being such a novice! thanks guys!

推荐答案

如果我正确阅读了ExoPlayer源代码,则必须保留对准备ExoPlayer实例时使用的audioRenderer的引用.

If I read the ExoPlayer source code correctly you have to keep references to the audioRenderers you use when preparing the ExoPlayer instance.

exoPlayer.prepare(audioRenderer);

要更改音量,您必须发送以下消息:

To change volume you have to send the following message:

exoPlayer.sendMessage(audioRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 0.1f);

首先,传递您要更改其音量的audioRenderer.其次,您要定义要发送到渲染器的消息,即MSG_SET_VOLUME,因为您想影响音频. 最后,传递您要设置音量的值.在此示例中,我选择了0.1f,但是您当然可以使用任何适合您需要的值.

First you pass the audioRenderer for which you want to change the volume. Secondly you define the message which you want to send to the renderer which is MSG_SET_VOLUME, since you want to affect audio. Finally you pass the value you want to set the volume to. In this example I chose 0.1f but of course you can use any value which fits your needs.

如果您将消息发送到用于准备播放的两个MediaCodecAudioTrackRenderers,则可以实现两个不同的播放音量.因此,您可以发送两条消息,例如,audioRenderer1的值为0.4f,audioRenderer2的值为0.6f,以使回放相互融合.

You can effect two different playback volumes if you send messages to both MediaCodecAudioTrackRenderers which you used to prepare playback. So you could send two messages with for example value 0.4f for audioRenderer1 and 0.6f for audioRenderer2 to blend the playbacks into one another.

我自己没有尝试过,但是我认为它应该可以工作.

I did not try this myself, but I think it should work.

这是原始ExoPlayer代码的片段,该代码负责处理MSG_SET_VOLUME消息:

This is the snippet of the original ExoPlayer code which is responsible for handling the MSG_SET_VOLUME message:

public void handleMessage(int messageType, Object message) throws ExoPlaybackException {
    if (messageType == MSG_SET_VOLUME) {
        audioTrack.setVolume((Float) message);
    } else {
        super.handleMessage(messageType, message);
    }
}

这篇关于使用Android Exoplayer调整Dash流的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆