Commit 34fa7a66 by TadejZupancic

Add option to add playback speed button and audio track selection button via…

Add option to add playback speed button and audio track selection button via xml. So far only settings button existed that opened a submenu with the playback speed button and audio track selection button.
parent 9faa393a
...@@ -455,6 +455,9 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -455,6 +455,9 @@ public class StyledPlayerControlView extends FrameLayout {
@Nullable private ImageView fullScreenButton; @Nullable private ImageView fullScreenButton;
@Nullable private ImageView minimalFullScreenButton; @Nullable private ImageView minimalFullScreenButton;
@Nullable private View settingsButton; @Nullable private View settingsButton;
@Nullable private View playbackSpeedButton;
@Nullable private View audioTrackButton;
public StyledPlayerControlView(Context context) { public StyledPlayerControlView(Context context) {
this(context, /* attrs= */ null); this(context, /* attrs= */ null);
...@@ -573,6 +576,16 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -573,6 +576,16 @@ public class StyledPlayerControlView extends FrameLayout {
settingsButton.setOnClickListener(componentListener); settingsButton.setOnClickListener(componentListener);
} }
playbackSpeedButton = findViewById(R.id.exo_playback_speed);
if (playbackSpeedButton != null) {
playbackSpeedButton.setOnClickListener(componentListener);
}
audioTrackButton = findViewById(R.id.exo_audio_track);
if (audioTrackButton != null) {
audioTrackButton.setOnClickListener(componentListener);
}
TimeBar customTimeBar = findViewById(R.id.exo_progress); TimeBar customTimeBar = findViewById(R.id.exo_progress);
View timeBarPlaceholder = findViewById(R.id.exo_progress_placeholder); View timeBarPlaceholder = findViewById(R.id.exo_progress_placeholder);
if (customTimeBar != null) { if (customTimeBar != null) {
...@@ -1871,6 +1884,12 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -1871,6 +1884,12 @@ public class StyledPlayerControlView extends FrameLayout {
} else if (settingsButton == view) { } else if (settingsButton == view) {
controlViewLayoutManager.removeHideCallbacks(); controlViewLayoutManager.removeHideCallbacks();
displaySettingsWindow(settingsAdapter); displaySettingsWindow(settingsAdapter);
} else if (playbackSpeedButton == view) {
controlViewLayoutManager.removeHideCallbacks();
onSettingViewClicked(SETTINGS_PLAYBACK_SPEED_POSITION);
} else if (audioTrackButton == view) {
controlViewLayoutManager.removeHideCallbacks();
onSettingViewClicked(SETTINGS_AUDIO_TRACK_SELECTION_POSITION);
} else if (subtitleButton == view) { } else if (subtitleButton == view) {
controlViewLayoutManager.removeHideCallbacks(); controlViewLayoutManager.removeHideCallbacks();
displaySettingsWindow(textTrackSelectionAdapter); displaySettingsWindow(textTrackSelectionAdapter);
......
...@@ -65,6 +65,7 @@ import com.google.android.exoplayer2.ui.spherical.SingleTapListener; ...@@ -65,6 +65,7 @@ import com.google.android.exoplayer2.ui.spherical.SingleTapListener;
import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView; import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ErrorMessageProvider; import com.google.android.exoplayer2.util.ErrorMessageProvider;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.RepeatModeUtil; import com.google.android.exoplayer2.util.RepeatModeUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView; import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
...@@ -594,6 +595,7 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro ...@@ -594,6 +595,7 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
subtitleView.setCues(null); subtitleView.setCues(null);
} }
this.player = player; this.player = player;
Log.d("test track", this.player.getTrackSelector().toString());
if (useController()) { if (useController()) {
controller.setPlayer(player); controller.setPlayer(player);
} }
......
...@@ -41,4 +41,7 @@ ...@@ -41,4 +41,7 @@
<item name="exo_vr" type="id"/> <item name="exo_vr" type="id"/>
<item name="exo_subtitle" type="id"/> <item name="exo_subtitle" type="id"/>
<item name="exo_fullscreen" type="id"/> <item name="exo_fullscreen" type="id"/>
<item name="exo_settings" type="id"/>
<item name="exo_playback_speed" type="id"/>
<item name="exo_audio_track" type="id"/>
</resources> </resources>
...@@ -192,6 +192,16 @@ ...@@ -192,6 +192,16 @@
<item name="android:contentDescription">@string/exo_controls_settings_description</item> <item name="android:contentDescription">@string/exo_controls_settings_description</item>
</style> </style>
<style name="ExoStyledControls.Button.Bottom.PlaybackSpeed">
<item name="android:src">@drawable/exo_styled_controls_speed</item>
<item name="android:contentDescription">@string/exo_controls_playback_speed</item>
</style>
<style name="ExoStyledControls.Button.Bottom.AudioTrack">
<item name="android:src">@drawable/exo_styled_controls_audiotrack</item>
<item name="android:contentDescription">@string/exo_track_selection_title_audio</item>
</style>
<style name="ExoStyledControls.TimeBar"> <style name="ExoStyledControls.TimeBar">
<item name="bar_height">@dimen/exo_styled_progress_bar_height</item> <item name="bar_height">@dimen/exo_styled_progress_bar_height</item>
<item name="bar_gravity">bottom</item> <item name="bar_gravity">bottom</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment