diff --git a/app/src/main/java/org/xbmc/kore/ui/NowPlayingFragment.java b/app/src/main/java/org/xbmc/kore/ui/NowPlayingFragment.java index 0c7ac87..cd24a1c 100644 --- a/app/src/main/java/org/xbmc/kore/ui/NowPlayingFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/NowPlayingFragment.java @@ -222,6 +222,16 @@ public class NowPlayingFragment extends Fragment public void onResume() { super.onResume(); hostConnectionObserver.registerPlayerObserver(this, true); + Application.GetProperties action = new Application.GetProperties(Application.GetProperties.MUTED); + action.execute(hostManager.getConnection(), new ApiCallback() { + @Override + public void onSuccess(ApplicationType.PropertyValue result) { + setVolumeMuteButton(result.muted); + } + + @Override + public void onError(int errorCode, String description) { } + }, callbackHandler); } @Override @@ -311,18 +321,7 @@ public class NowPlayingFragment extends Fragment action.execute(hostManager.getConnection(), new ApiCallback() { @Override public void onSuccess(Boolean result) { - if (!isAdded()) return; - if (result) { - Resources.Theme theme = getActivity().getTheme(); - TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { - R.attr.colorAccent}); - volumeMuteButton.setColorFilter( - styledAttributes.getColor(0, - getActivity().getResources().getColor(R.color.accent_default))); - styledAttributes.recycle(); - } else { - volumeMuteButton.clearColorFilter(); - } + setVolumeMuteButton(result); } @Override @@ -955,6 +954,25 @@ public class NowPlayingFragment extends Fragment } } + /** + * Sets the color of the mute volume button according to the player's status + * @param isMuted Whether the player is muted + */ + private void setVolumeMuteButton(Boolean isMuted) { + if (!isAdded()) return; + if (isMuted) { + Resources.Theme theme = getActivity().getTheme(); + TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { + R.attr.colorAccent}); + volumeMuteButton.setColorFilter( + styledAttributes.getColor(0, + getActivity().getResources().getColor(R.color.accent_default))); + styledAttributes.recycle(); + } else { + volumeMuteButton.clearColorFilter(); + } + } + /** * Seekbar change listener. Sends seek commands to XBMC based on the seekbar position */