3

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

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.

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!

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Max Marshall
  • 257
  • 2
  • 3
  • 13

1 Answers1

1

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

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.

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.

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);
    }
}
mismor
  • 605
  • 4
  • 13
  • Thanks for the input! This has given me some leads to follow however I am having trouble due to the fact that my renderers and players are all in different classes as per the demo, I am using the DashRendererBuilder and Player and Playeractivity classes to create the player and currently have the seekbar within the playeractivity class. Anyway as i have said I am quite a beginner so this is all a lot to take in and progress is slow at the moment! – Max Marshall Jul 21 '15 at 18:50
  • Do you really need the full functionality of the demo player? If not you can try to build your own player and make it much slimmer if you only need a fraction of the functionality. I use ExoPlayer only for standard and encrypted mp3s and it is easily manageable. – mismor Jul 22 '15 at 06:30
  • Yeah I am trying my best to slim it down at the moment, as I am streaming Dash content I am using a relatively large part of the project though and am slowly deleting what I can from it while retaining functionality :) Once I put my rendererbuilders in the same activity as my player I will be in an easier place to be able to send messages to both components. This is very much a cowboy job at the moment! But this seems to be my best option for now! Thanks again for your help! – Max Marshall Jul 22 '15 at 17:58