Commit 1d9eb49c authored by Geoffrey Métais's avatar Geoffrey Métais

Chapter navigation in video advanced option

parent 0e3d2ece
......@@ -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
......
......@@ -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&#8230;</string>
<string-array name="hardware_acceleration_list">
<item>@string/automatic</item>
......
......@@ -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);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment