[Android] Chapter navigation in video advanced option
Geoffrey Métais
git at videolan.org
Mon Mar 30 19:02:37 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 30 18:58:02 2015 +0200| [1d9eb49c146b2ed36d2ab7cb117c5f9641abe00b] | committer: Geoffrey Métais
Chapter navigation in video advanced option
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=1d9eb49c146b2ed36d2ab7cb117c5f9641abe00b
---
.../res/layout/fragment_advanced_options.xml | 32 +++++++++++----
vlc-android/res/values/strings.xml | 1 +
.../videolan/vlc/gui/video/AdvOptionsDialog.java | 41 ++++++++++++++++++--
3 files changed, 64 insertions(+), 10 deletions(-)
diff --git a/vlc-android/res/layout/fragment_advanced_options.xml b/vlc-android/res/layout/fragment_advanced_options.xml
index 9fc7fad..3ca462e 100644
--- a/vlc-android/res/layout/fragment_advanced_options.xml
+++ b/vlc-android/res/layout/fragment_advanced_options.xml
@@ -163,15 +163,33 @@
</LinearLayout>
<!-- Jump to position -->
- <TextView
- android:id="@+id/jump_title"
+
+ <LinearLayout
+ android:id="@+id/time_travel_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:clickable="true"
- android:focusable="true"
- android:gravity="center_vertical"
- android:text="@string/jump_to_time"
- android:drawableLeft="@drawable/ic_jumpto_normal_w"/>
+ android:layout_marginTop="10dp"
+ android:orientation="horizontal" >
+ <TextView
+ android:id="@+id/jump_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="true"
+ android:focusable="true"
+ android:gravity="center_vertical"
+ android:text="@string/jump_to_time"
+ android:drawableLeft="@drawable/ic_jumpto_normal_w"/>
+ <TextView
+ android:id="@+id/jump_chapter_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dp"
+ android:text="@string/go_to_chapter"/>
+ <Spinner
+ android:id="@+id/jump_chapter"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
<!-- Tracks delay -->
<LinearLayout
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 637b1ef..5f23d6f 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -328,6 +328,7 @@
<string name="directory_hide_medialib">Hide from MediaLib</string>
<string name="playlist_save">Save Playlist</string>
<string name="playlist_name_hint">playlist name</string>
+ <string name="go_to_chapter">Go to chapter…</string>
<string-array name="hardware_acceleration_list">
<item>@string/automatic</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
index 2372e78..f3baff5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
@@ -35,10 +35,14 @@ import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.SeekBar;
+import android.widget.Spinner;
import android.widget.TextView;
+import org.videolan.libvlc.LibVLC;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
@@ -82,10 +86,13 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private TextView mAudioDelay;
private TextView mSpuDelay;
+ private Spinner mChapters;
+ private TextView mChaptersTitle;
private static AdvOptionsDialog sInstance;
private int mTextColor;
private IDelayController mDelayController;
+ private LibVLC mLibVLC;
public AdvOptionsDialog() {}
@Override
@@ -95,6 +102,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
setStyle(STYLE_NO_FRAME, R.style.Theme_VLC_TransparentDialog);
if (VLCApplication.sPlayerSleepTime != null && VLCApplication.sPlayerSleepTime.before(Calendar.getInstance()))
VLCApplication.sPlayerSleepTime = null;
+ mLibVLC = VLCInstance.get();
}
@Override
@@ -132,6 +140,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
}
mJumpTitle = (TextView) root.findViewById(R.id.jump_title);
+ mChapters = (Spinner) root.findViewById(R.id.jump_chapter);
+ mChaptersTitle = (TextView) root.findViewById(R.id.jump_chapter_title);
mAudioDelay = (TextView) root.findViewById(R.id.audio_delay);
mSpuDelay = (TextView) root.findViewById(R.id.spu_delay);
@@ -152,11 +162,12 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mAudioDelay.setVisibility(View.GONE);
}
+ initChapterSpinner();
getDialog().setCancelable(true);
mHandler.sendEmptyMessage(TOGGLE_CANCEL);
mTextColor = mSleepTitle.getCurrentTextColor();
- double speed = VLCInstance.get().getRate();
+ double speed = mLibVLC.getRate();
if (speed != 1.0d) {
speed = 100 * (1 + Math.log(speed) / Math.log(4));
mSeek.setProgress((int) speed);
@@ -164,12 +175,36 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
return root;
}
+ private void initChapterSpinner() {
+ int chaptersCount = mLibVLC.getChapterCount();
+ if (chaptersCount <= 1){
+ mChapters.setVisibility(View.GONE);
+ mChaptersTitle.setVisibility(View.GONE);
+ return;
+ }
+ ArrayAdapter<Integer> adapter = new ArrayAdapter<Integer>(getActivity(), android.R.layout.simple_spinner_item);
+ for (int i = 0 ; i < chaptersCount ; ++i)
+ adapter.insert(i, i);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mChapters.setAdapter(adapter);
+ mChapters.setSelection(mLibVLC.getChapter());
+ mChapters.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ if (position != mLibVLC.getChapter())
+ mLibVLC.setChapter(position);
+ }
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {}
+ });
+ }
+
private SeekBar.OnSeekBarChangeListener mSeekBarListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
float rate = (float) Math.pow(4, ((double) progress / (double) 100) - 1);
mHandler.obtainMessage(SPEED_TEXT, Strings.formatRateString(rate)).sendToTarget();
- VLCInstance.get().setRate(rate);
+ mLibVLC.setRate(rate);
}
public void onStartTrackingTouch(SeekBar seekBar) {}
@@ -180,7 +215,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
@Override
public void onClick(View v) {
mSeek.setProgress(100);
- VLCInstance.get().setRate(1);
+ mLibVLC.setRate(1);
}
};
More information about the Android
mailing list