Adjust your streaming traffic with Android Exoplayer

I am trying to set up a search barrier to control the level of an instance of a streaming streaming game exoplayer.

The setup I'm using is a modified version of the demo project and I'm having a hard time figuring out which element I should be trying to influence the search engine output, like how to properly use MSG_SET_VOLUME, etc. etc. Any entry would be appreciated by weight.

The end result I'm looking for is an app with two instances of exoplayer and a streaming dash with a fader (search) controlling the connection of the two players (which, once it is figured out, I suppose should be simple enough if the math is correct) Any help again would be judged by weight. I didn't have much time when Exoplayer was such a newbie! Thanks guys!

+3


source to share


1 answer


If I read the ExoPlayer source code correctly, you need to keep the links to the audio editors that you use when preparing the ExoPlayer instance.

exoPlayer.prepare(audioRenderer);

      

To change the volume, you must send the following message:

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

      

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



You can use two different playback volumes if you post messages to the MediaCodecAudioTrackRenderers that you used to prepare the playback. So you can send two messages, for example 0.4f for audioRenderer1 and 0.6f for audioRenderer2, to mix the playback with each other.

I haven't tried this myself, but I think it should work.

This is the ExoPlayer source code snippet that 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);
    }
}

      

+1


source







All Articles