From 35c5713b0a30bef3898a29e79c39d1f4d088548d Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 5 Dec 2020 14:01:08 +0100 Subject: [PATCH] #123 - some tests --- .../fedilab/fedilabtube/PeertubeActivity.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 524777e..dac6658 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -161,6 +161,7 @@ import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.RATE import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO; +import static app.fedilab.fedilabtube.helper.Helper.CAST_ID; import static app.fedilab.fedilabtube.helper.Helper.getAttColor; import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; import static app.fedilab.fedilabtube.helper.Helper.loadGiF; @@ -724,10 +725,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd Status status = chromeCast.getStatus(); - String app_id = status.getRunningApp().id; Application app = null; - if (chromeCast.isAppAvailable(app_id) && !status.isAppRunning(app_id)) { - chromeCast.launchApp(app_id); + if (chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) { + chromeCast.launchApp(CAST_ID); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -736,7 +736,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd dialog.dismiss(); }; mainHandler.post(myRunnable); - if (status.isAppRunning(app_id) && chromeCastVideoURL != null) { + if (status.isAppRunning(CAST_ID) && chromeCastVideoURL != null) { app = status.getRunningApp(); chromeCast.load(peertube.getTitle(), "https://" + HelperInstance.getLiveInstance(PeertubeActivity.this) + peertube.getThumbnailPath(), chromeCastVideoURL, null); //chromeCast.send( app.namespaces.get(app.namespaces.size()-1).name, new DashCastRequest(chromeCastVideoURL, true, false, 0)); @@ -1342,11 +1342,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd torrentStream.stopStream(); } if (chromeCast != null) { - try { - chromeCast.disconnect(); - } catch (IOException e) { - e.printStackTrace(); - } + new Thread(() -> { + try { + chromeCast.disconnect(); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); } unregisterReceiver(); }