diff --git a/app/src/acad/res/values/strings.xml b/app/src/acad/res/values/strings.xml
index 8b6952b..0a5cbc0 100644
--- a/app/src/acad/res/values/strings.xml
+++ b/app/src/acad/res/values/strings.xml
@@ -22,6 +22,7 @@
ChromeCast
Permet de découvrir les appareils Chromecast sur le réseau.
Choix de la ChromeCast
+ Veuillez patienter
Réessayer
Échec de rafraîchissement du jeton d\'accès
Vous pouvez réessayer de le rafraîchir ou simplement déconnecter le compte
diff --git a/app/src/bittube/res/values/strings.xml b/app/src/bittube/res/values/strings.xml
index 55439ff..4a6233d 100644
--- a/app/src/bittube/res/values/strings.xml
+++ b/app/src/bittube/res/values/strings.xml
@@ -1,5 +1,5 @@
- Bittube
+ bittube
app.fedilab.bittube
set_video_mode_choice
set_video_minimize_choice
@@ -13,6 +13,10 @@
set_fullscreen_choice
set_play_screen_lock_choice
set_video_in_list_choice
+ set_cast_choice
+ Enable Chromecast (beta)
+ Please wait
+ Allow to discover Chromecast devices on the network.
set_video_sensitive_choice
Videos in list
Change the layout for displaying videos in a list
@@ -21,6 +25,7 @@
Show less
ChromeCast
ChromeCast choice
+
Screen lock
Keep playing videos when the screen is locked
diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml
index e2503bc..38187a9 100644
--- a/app/src/full/res/values/strings.xml
+++ b/app/src/full/res/values/strings.xml
@@ -15,6 +15,7 @@
set_video_in_list_choice
set_cast_choice
Enable Chromecast (beta)
+ Please wait
Allow to discover Chromecast devices on the network.
set_video_sensitive_choice
Videos in list
diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
index 0f9f8b3..ada390f 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
@@ -152,6 +152,7 @@ import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
import app.fedilab.fedilabtube.webview.MastalabWebViewClient;
import es.dmoral.toasty.Toasty;
import su.litvak.chromecast.api.v2.ChromeCast;
+import su.litvak.chromecast.api.v2.MediaStatus;
import su.litvak.chromecast.api.v2.Status;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT;
@@ -446,6 +447,35 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
});
+ binding.castPlay.setOnClickListener(v -> {
+ binding.castLoader.setVisibility(View.VISIBLE);
+ if (chromeCast != null) {
+ new Thread(() -> {
+ try {
+ int icon = -1;
+ if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PLAYING) {
+ chromeCast.pause();
+ icon = R.drawable.ic_baseline_play_arrow_32;
+ } else if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PAUSED) {
+ chromeCast.play();
+ icon = R.drawable.ic_baseline_pause_32;
+ }
+ if (icon != -1) {
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ int finalIcon = icon;
+ Runnable myRunnable = () -> binding.castPlay.setImageResource(finalIcon);
+ mainHandler.post(myRunnable);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> binding.castLoader.setVisibility(View.GONE);
+ mainHandler.post(myRunnable);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+ });
+
}
private void manageVIewVideos(APIResponse apiResponse) {
@@ -713,6 +743,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
try {
chromeCast.disconnect();
chromeCast = null;
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
+ binding.castController.setVisibility(View.GONE);
+ };
+ mainHandler.post(myRunnable);
+
} catch (IOException e) {
e.printStackTrace();
}
@@ -721,24 +758,35 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
invalidateOptionsMenu();
+ binding.castLoader.setVisibility(View.VISIBLE);
player.setPlayWhenReady(false);
+ binding.doubleTapPlayerView.setVisibility(View.GONE);
+ binding.castController.setVisibility(View.VISIBLE);
dialog.dismiss();
};
+ mainHandler.post(myRunnable);
if (!chromeCast.isConnected()) {
chromeCast.connect();
}
+ myRunnable = this::invalidateOptionsMenu;
+ mainHandler.post(myRunnable);
Status status = chromeCast.getStatus();
if (chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) {
chromeCast.launchApp(CAST_ID);
}
- mainHandler.post(myRunnable);
+
if (chromeCastVideoURL != null) {
+ if (player != null && player.getCurrentPosition() > 0) {
+ chromeCastVideoURL += "?start=" + (player.getCurrentPosition() / 1000);
+ }
String mime = MimeTypeMap.getFileExtensionFromUrl(chromeCastVideoURL);
chromeCast.setRequestTimeout(120000);
chromeCast.load(peertube.getTitle(), null, chromeCastVideoURL, mime);
chromeCast.play();
+ binding.castPlay.setImageResource(R.drawable.ic_baseline_pause_32);
}
-
+ myRunnable = () -> binding.castLoader.setVisibility(View.GONE);
+ mainHandler.post(myRunnable);
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
@@ -1301,6 +1349,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override
public void onConfigurationChanged(@NotNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ if (binding.castController.getVisibility() == View.VISIBLE) {
+ return;
+ }
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
openFullscreenDialog();
@@ -1376,7 +1427,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
if (player != null && (!isPlayInMinimized || !playInMinimized)) {
player.setPlayWhenReady(false);
- } else if (playInMinimized) {
+ } else if (playInMinimized && binding.castController.getVisibility() != View.VISIBLE) {
enterVideoMode();
}
}
diff --git a/app/src/main/res/drawable/ic_baseline_pause_32.xml b/app/src/main/res/drawable/ic_baseline_pause_32.xml
new file mode 100644
index 0000000..bd68772
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_pause_32.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_baseline_play_arrow_32.xml b/app/src/main/res/drawable/ic_baseline_play_arrow_32.xml
new file mode 100644
index 0000000..d59ca86
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_play_arrow_32.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_peertube.xml b/app/src/main/res/layout/activity_peertube.xml
index 28a2995..43d324a 100644
--- a/app/src/main/res/layout/activity_peertube.xml
+++ b/app/src/main/res/layout/activity_peertube.xml
@@ -67,6 +67,59 @@
app:yt_playerView="@+id/doubleTapPlayerView"
android:gravity="center" />
+
+
+
+
+
+
+
+
+
+
+
+
+