diff --git a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java index 88dbc54a6..c56e27e53 100644 --- a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java +++ b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java @@ -189,7 +189,11 @@ public class CastActivity extends BaseActivity implements CustomKeyDownCast.List } private void onDecode() { - mPlayers.toggleDecode(); + onDecode(true); + } + + private void onDecode(boolean save) { + mPlayers.toggleDecode(save); mPlayers.set(mBinding.exo); setDecode(); onReset(); @@ -334,7 +338,7 @@ public class CastActivity extends BaseActivity implements CustomKeyDownCast.List @Subscribe(threadMode = ThreadMode.MAIN) public void onErrorEvent(ErrorEvent event) { - if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(); + if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(false); else if (mPlayers.addRetry() > 1) onError(event); else onReset(); } diff --git a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java index 2bbc56039..6688be1e9 100644 --- a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java +++ b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java @@ -3,9 +3,7 @@ package com.fongmi.android.tv.ui.activity; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.support.v4.media.MediaMetadataCompat; import android.view.KeyEvent; import android.view.View; @@ -380,7 +378,11 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick } private void onDecode() { - mPlayers.toggleDecode(); + onDecode(true); + } + + private void onDecode(boolean save) { + mPlayers.toggleDecode(save); mPlayers.set(mBinding.exo); setDecode(); fetch(); @@ -712,7 +714,7 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick @Subscribe(threadMode = ThreadMode.MAIN) public void onErrorEvent(ErrorEvent event) { - if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(); + if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(false); else if (mPlayers.addRetry() > 1) onError(event); else fetch(); } diff --git a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java index 3f528ad8c..4105bbf4e 100644 --- a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java +++ b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java @@ -835,7 +835,11 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List } private void onDecode() { - mPlayers.toggleDecode(); + onDecode(true); + } + + private void onDecode(boolean save) { + mPlayers.toggleDecode(save); mPlayers.set(mBinding.exo); setDecode(); onRefresh(); @@ -1130,7 +1134,7 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List @Subscribe(threadMode = ThreadMode.MAIN) public void onErrorEvent(ErrorEvent event) { if (isBackground()) return; - if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(); + if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(false); else if (mPlayers.addRetry() > 1) onError(event); else onRefresh(); } diff --git a/app/src/main/java/com/fongmi/android/tv/player/Players.java b/app/src/main/java/com/fongmi/android/tv/player/Players.java index b64d56a86..7663cd3c7 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/Players.java +++ b/app/src/main/java/com/fongmi/android/tv/player/Players.java @@ -261,9 +261,9 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac return setSpeed(speed); } - public void toggleDecode() { + public void toggleDecode(boolean save) { setDecode(decode == HARD ? SOFT : HARD); - Setting.putDecode(decode); + if (save) Setting.putDecode(decode); } public String getPositionTime(long time) { diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java index 2b12a0553..5b2c6246e 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java @@ -409,7 +409,11 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List } private void onDecode() { - mPlayers.toggleDecode(); + onDecode(true); + } + + private void onDecode(boolean save) { + mPlayers.toggleDecode(save); mPlayers.set(mBinding.exo); setR1Callback(); setDecode(); @@ -769,7 +773,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List @Subscribe(threadMode = ThreadMode.MAIN) public void onErrorEvent(ErrorEvent event) { - if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(); + if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(false); else if (mPlayers.addRetry() > 1) onError(event); else fetch(); } diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java index 511edba92..b3cbb0371 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java @@ -7,7 +7,6 @@ import android.app.Dialog; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -760,7 +759,11 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo } private void onDecode() { - mPlayers.toggleDecode(); + onDecode(true); + } + + private void onDecode(boolean save) { + mPlayers.toggleDecode(save); mPlayers.set(mBinding.exo); setR1Callback(); setDecode(); @@ -1141,7 +1144,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo @Subscribe(threadMode = ThreadMode.MAIN) public void onErrorEvent(ErrorEvent event) { if (isRedirect()) return; - if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(); + if (event.getCode() / 1000 == 4 && Players.isHard()) onDecode(false); else if (mPlayers.addRetry() > 1) onError(event); else onRefresh(); }