How to create a search and volume control user interface for ExoPlayer in Android

I tried this one and this one for the search user interface for ExoPlayer, but no luck.

I want to create a custom finger and a ProgressBar for ExoPlayer. Below is the XML file for ExoPlayer, where I tried to set the search, but it does not fit as expected.

<com.google.android.exoplayer.AspectRatioFrameLayout android:id="@+id/video_frame" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center"> <SurfaceView android:id="@+id/surface_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center"/> <View android:id="@+id/shutter" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black"/> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:thumb="@drawable/thumb"/> <com.google.android.exoplayer.text.SubtitleLayout android:id="@+id/subtitles" android:layout_width="match_parent" android:layout_height="match_parent"/> </com.google.android.exoplayer.AspectRatioFrameLayout> 

One more question: how can I set up custom volume controls for ExoPlayer, for example, we have this in MXPlayer (vertical bar for the volume).

Update

I have a SeekBar using this method.

 SeekBar seekBar = (SeekBar) mediaController.findViewById(getResources().getIdentifier("mediacontroller_progress","id","android")); seekBar.setThumb(getResources().getDrawable(R.drawable.player_thumb)); 

Now the only thing you need to do to control vertical volume, for example MXPlayer .

0
source share
2 answers

I created a solution that works (at least for me, anyway) and creates a vertical SeekBar. Create a Java class as follows. Hope this helps you.

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); 
+2
source

AudioManager is useful for processing system volumes. I performed the horizontal volume of Seekbar to control the sound volume using ExoPlayer . Just use this:

Create an AudioManager object:

  AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 

Knob Volume Up / Down Hardware Button:

  @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN){ volumeSeekBar.setProgress(audioManager.getStreamVolume(exoPlayer.getAudioStreamType())); } return super.onKeyDown(keyCode, event); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP){ volumeSeekBar.setProgress(audioManager.getStreamVolume(exoPlayer.getAudioStreamType())); } return super.onKeyUp(keyCode, event); } 

Handle volume with Seekbar:

 volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { audioManager.setStreamVolume(exoPlayer.getAudioStreamType(), i, 0); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); 
+1
source

All Articles