[Android] Video : Add repeat mode advanced option
Alexandre Perraud
git at videolan.org
Fri Apr 8 17:56:19 CEST 2016
vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu Apr 7 18:13:52 2016 +0200| [1059d9709004f9af47ac88e698595f2fbef176d2] | committer: Alexandre Perraud
Video : Add repeat mode advanced option
> https://code.videolan.org/videolan/vlc-android/commit/1059d9709004f9af47ac88e698595f2fbef176d2
---
vlc-android/res/values/styles.xml | 1 +
.../videolan/vlc/gui/dialogs/AdvOptionsDialog.java | 50 ++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index bd56135..31fcf19 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -213,6 +213,7 @@
<item name="ic_equalizer_normal_style">@drawable/ic_equalizer_w</item>
<item name="ic_audiodelay">@drawable/ic_audiodelay_w</item>
<item name="ic_subtitledelay">@drawable/ic_subtitledelay_w</item>
+ <item name="ic_repeat">@drawable/ic_repeat_w</item>
<item name="list_subtitle">@color/grey400</item>
<item name="list_title_last">@color/list_title_last</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index 730315c..2528845 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -86,6 +86,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private static final int ID_EQUALIZER = 7 ;
private static final int ID_SAVE_PLAYLIST = 8 ;
private static final int ID_POPUP_VIDEO = 9 ;
+ private static final int ID_REPEAT = 10 ;
private Activity mActivity;
private int mTheme;
@@ -102,6 +103,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private TextView mAudioDelay;
private TextView mSpuDelay;
+ private TextView mRepeat;
+
private TextView mChaptersTitle;
private int mTextColor;
private PlaybackService mService;
@@ -318,6 +321,41 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
}
}
+ public void initRepeat() {
+ switch (mService.getRepeatType()) {
+ case PlaybackService.REPEAT_NONE:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0,
+ UiTools.getResourceFromAttribute(mActivity, R.attr.ic_repeat),
+ 0, 0);
+ break;
+ case PlaybackService.REPEAT_ALL:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_repeat_on, 0, 0);
+ break;
+ case PlaybackService.REPEAT_ONE:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_repeat_one, 0, 0);
+ break;
+ }
+ }
+
+ public void setRepeatMode() {
+ switch (mService.getRepeatType()) {
+ case PlaybackService.REPEAT_NONE:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_repeat_one, 0, 0);
+ mService.setRepeatType(PlaybackService.REPEAT_ONE);
+ break;
+ case PlaybackService.REPEAT_ONE:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_repeat_on, 0, 0);
+ mService.setRepeatType(PlaybackService.REPEAT_ALL);
+ break;
+ case PlaybackService.REPEAT_ALL:
+ mRepeat.setCompoundDrawablesWithIntrinsicBounds(0,
+ UiTools.getResourceFromAttribute(mActivity, R.attr.ic_repeat),
+ 0, 0);
+ mService.setRepeatType(PlaybackService.REPEAT_NONE);
+ break;
+ }
+ }
+
private void initChapters() {
final MediaPlayer.Chapter[] chapters = mService.getChapters(-1);
@@ -363,6 +401,10 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mSpuDelay = tv;
initSpuDelay();
break;
+ case ID_REPEAT:
+ mRepeat = tv;
+ initRepeat();
+ break;
}
}
@@ -415,6 +457,9 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
case ID_SAVE_PLAYLIST:
showFragment(ID_SAVE_PLAYLIST);
break;
+ case ID_REPEAT:
+ setRepeatMode();
+ break;
}
}
@@ -432,6 +477,10 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mService.setAudioDelay(0l);
initAudioDelay();
return true;
+ case ID_REPEAT:
+ mService.setRepeatType(PlaybackService.REPEAT_NONE);
+ initRepeat();
+ return true;
}
return false;
}
@@ -488,6 +537,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mAdapter.addOption(new Option(ID_AUDIO_DELAY, R.attr.ic_audiodelay));
if (!tvUi)
mAdapter.addOption(new Option(ID_POPUP_VIDEO, R.attr.ic_popup_dim));
+ mAdapter.addOption(new Option(ID_REPEAT, R.attr.ic_repeat));
final MediaPlayer.Chapter[] chapters = mService.getChapters(-1);
final int chaptersCount = chapters != null ? chapters.length : 0;
More information about the Android
mailing list