diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
index 5c563a9..fa781a2 100644
--- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
@@ -245,11 +245,6 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
ImageButton moreButton = findViewById(R.id.moreButton);
ImageButton videoOptions = findViewById(R.id.exo_more);
- //Playback speed buttons
- Button speed05 = findViewById(R.id.speed05);
- Button speed10 = findViewById(R.id.speed10);
- Button speed15 = findViewById(R.id.speed15);
- Button speed20 = findViewById(R.id.speed20);
Video video = response.body();
@@ -296,50 +291,17 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
popup.show();
});
+ // video player options
videoOptions.setOnClickListener(v -> {
VideoOptionsFragment videoOptionsFragment =
- VideoOptionsFragment.newInstance();
+ VideoOptionsFragment.newInstance(mService);
videoOptionsFragment.show(getSupportFragmentManager(),
"video_options_fragment");
});
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
- //Playback speed controls
- speed05.setOnClickListener(view -> {
- mService.setPlayBackSpeed(0.5f);
- speed05.setTextColor(getResources().getColor(R.color.primaryColorRed));
-
- speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
-
- });
- speed10.setOnClickListener(view -> {
- mService.setPlayBackSpeed(1.0f);
- speed10.setTextColor(getResources().getColor(R.color.primaryColorRed));
-
- speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- });
- speed15.setOnClickListener(view -> {
- mService.setPlayBackSpeed(1.5f);
- speed15.setTextColor(getResources().getColor(R.color.primaryColorRed));
-
- speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- });
- speed20.setOnClickListener(view -> {
- mService.setPlayBackSpeed(2.0f);
- speed20.setTextColor(getResources().getColor(R.color.primaryColorRed));
-
- speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
- });
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (sharedPref.getBoolean("pref_torrent_player", false)) {
diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java
index 27bf542..d2a9cf9 100644
--- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java
+++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java
@@ -4,16 +4,21 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.TextView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import net.schueller.peertube.R;
+import net.schueller.peertube.service.VideoPlayerService;
import androidx.annotation.Nullable;
public class VideoOptionsFragment extends BottomSheetDialogFragment {
- public static VideoOptionsFragment newInstance() {
+ private static VideoPlayerService videoPlayerService;
+
+ public static VideoOptionsFragment newInstance(VideoPlayerService mService) {
+ videoPlayerService = mService;
return new VideoOptionsFragment();
}
@@ -28,6 +33,18 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
// get the views and attach the listener
+ //Playback speed buttons
+ TextView speed05 = view.findViewById(R.id.video_speed05);
+ TextView speed10 = view.findViewById(R.id.video_speed10);
+ TextView speed15 = view.findViewById(R.id.video_speed15);
+ TextView speed20 = view.findViewById(R.id.video_speed20);
+
+ //Playback speed controls
+ speed05.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(0.5f));
+ speed10.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.0f));
+ speed15.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.5f));
+ speed20.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(2.0f));
+
return view;
}
diff --git a/app/src/main/res/layout/activity_video_play.xml b/app/src/main/res/layout/activity_video_play.xml
index 0bb4c66..6e38fce 100644
--- a/app/src/main/res/layout/activity_video_play.xml
+++ b/app/src/main/res/layout/activity_video_play.xml
@@ -109,50 +109,6 @@
android:layout_marginEnd="12dp"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1" />
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml
index 7646e31..c016aca 100644
--- a/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml
+++ b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml
@@ -1,24 +1,65 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index efb5081..f3a20a0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -84,5 +84,9 @@
Brown
Gray
Bluegray
+ 0.5x
+ Normal
+ 1.5x
+ 2x