Commit 8bfb126a authored by Geoffrey Métais's avatar Geoffrey Métais

New delay UI for touch devices

parent 874d1beb
......@@ -76,6 +76,23 @@
android:textColor="#ffffff"
android:textSize="36sp"
android:visibility="invisible" />
<ImageView
android:id="@+id/player_delay_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/progress_overlay"
android:layout_alignParentRight="true"
android:src="@android:drawable/btn_minus"
android:visibility="invisible"/>
<ImageView
android:id="@+id/player_delay_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_above="@+id/player_delay_minus"
android:layout_alignParentRight="true"
android:src="@android:drawable/btn_plus"
android:visibility="invisible"/>
<include layout="@layout/player_hud"/>
......
......@@ -21,6 +21,7 @@
*/
package org.videolan.vlc.gui.video;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
......@@ -47,6 +48,7 @@ import org.videolan.vlc.gui.dialogs.JumpToTimeDialog;
import org.videolan.vlc.gui.dialogs.PickTimeFragment;
import org.videolan.vlc.gui.dialogs.SubsDelayDialog;
import org.videolan.vlc.gui.dialogs.TimePickerDialogFragment;
import org.videolan.vlc.interfaces.IDelayController;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Strings;
......@@ -79,6 +81,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private static AdvOptionsDialog sInstance;
private int mTextColor;
private IDelayController mDelayController;
public AdvOptionsDialog() {}
@Override
......@@ -90,6 +93,12 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
VLCApplication.sPlayerSleepTime = null;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mDelayController = (IDelayController) activity;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
......@@ -159,21 +168,35 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
};
private void showTimePickerFragment(int action) {
DialogFragment newFragment;
switch (action){
case PickTimeFragment.ACTION_AUDIO_DELAY:
newFragment = new AudioDelayDialog();
break;
case PickTimeFragment.ACTION_SPU_DELAY:
newFragment = new SubsDelayDialog();
break;
case PickTimeFragment.ACTION_JUMP_TO_TIME:
newFragment = new JumpToTimeDialog();
break;
default:
return;
DialogFragment newFragment = null;
if (AndroidDevices.hasTsp()) {
switch (action){
case PickTimeFragment.ACTION_AUDIO_DELAY:
mDelayController.showAudioDelaySetting();
break;
case PickTimeFragment.ACTION_SPU_DELAY:
mDelayController.showSubsDelaySetting();
break;
case PickTimeFragment.ACTION_JUMP_TO_TIME:
newFragment = new JumpToTimeDialog();
break;
default:
return;
}
} else {
switch (action){
case PickTimeFragment.ACTION_AUDIO_DELAY:
newFragment = new AudioDelayDialog();
break;
case PickTimeFragment.ACTION_SPU_DELAY:
newFragment = new SubsDelayDialog();
break;
default:
return;
}
}
newFragment.show(getActivity().getSupportFragmentManager(), "time");
if (newFragment != null)
newFragment.show(getActivity().getSupportFragmentManager(), "time");
dismiss();
}
......
......@@ -20,46 +20,6 @@
package org.videolan.vlc.gui.video;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.StreamCorruptedException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaWrapperListPlayer;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.audio.AudioServiceController;
import org.videolan.vlc.gui.CommonDialogs;
import org.videolan.vlc.gui.CommonDialogs.MenuType;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.PreferencesActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.KeyguardManager;
......@@ -132,7 +92,47 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlayer, GestureDetector.OnDoubleTapListener {
import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.MediaWrapperListPlayer;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.audio.AudioServiceController;
import org.videolan.vlc.gui.CommonDialogs;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.PreferencesActivity;
import org.videolan.vlc.interfaces.IDelayController;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.StreamCorruptedException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlayer, GestureDetector.OnDoubleTapListener, IDelayController {
public final static String TAG = "VLC/VideoPlayerActivity";
......@@ -180,6 +180,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
private static final int FADE_OUT_INFO = 4;
private boolean mDragging;
private boolean mShowing;
private DelayState mDelay = DelayState.OFF;
private int mUiVisibility = -1;
private SeekBar mSeekbar;
private TextView mTitle;
......@@ -194,6 +195,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
private ImageView mPlayPause;
private ImageView mTracks;
private ImageView mAdvOptions;
private ImageView mDelayPlus;
private ImageView mDelayMinus;
private boolean mEnableBrightnessGesture;
private boolean mEnableCloneMode;
private boolean mDisplayRemainingTime = false;
......@@ -378,6 +381,9 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
mSize = (ImageView) findViewById(R.id.player_overlay_size);
mSize.setOnClickListener(mSizeListener);
mDelayPlus = (ImageView) findViewById(R.id.player_delay_plus);
mDelayMinus = (ImageView) findViewById(R.id.player_delay_minus);
try {
mLibVLC = VLCInstance.getLibVlcInstance();
} catch (LibVlcException e) {
......@@ -932,6 +938,77 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
mHandler.sendMessage(msg);
}
@Override
public void showAudioDelaySetting() {
mDelay = DelayState.AUDIO;
showDelayControls();
}
@Override
public void showSubsDelaySetting() {
mDelay = DelayState.SUBS;
showDelayControls();
}
public void showDelayControls(){
mDelayMinus.setOnClickListener(mAudioDelayListener);
mDelayPlus.setOnClickListener(mAudioDelayListener);
mDelayMinus.setVisibility(View.VISIBLE);
mDelayPlus.setVisibility(View.VISIBLE);
mInfo.setVisibility(View.VISIBLE);
String text = "";
if (mDelay == DelayState.AUDIO)
text += mLibVLC.getAudioDelay()/1000l;
else if (mDelay == DelayState.SUBS)
text += mLibVLC.getSpuDelay()/1000l;
else
text += "0";
text += " ms";
mInfo.setText(text);
}
@Override
public void endDelaySetting() {
mDelay = DelayState.OFF;
mDelayMinus.setOnClickListener(null);
mDelayPlus.setOnClickListener(null);
mDelayMinus.setVisibility(View.INVISIBLE);
mDelayPlus.setVisibility(View.INVISIBLE);
mInfo.setVisibility(View.INVISIBLE);
mInfo.setText("");
}
private OnClickListener mAudioDelayListener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.player_delay_minus:
if (mDelay == DelayState.AUDIO)
delayAudio(-50000);
else if (mDelay == DelayState.SUBS)
delaySubs(-50000);
break;
case R.id.player_delay_plus:
if (mDelay == DelayState.AUDIO)
delayAudio(50000);
else if (mDelay == DelayState.SUBS)
delaySubs(50000);
break;
}
}
};
public void delayAudio(long delta){
long delay = mLibVLC.getAudioDelay()+delta;
mLibVLC.setAudioDelay(delay);
mInfo.setText((delay/1000l)+" ms");
}
public void delaySubs(long delta){
long delay = mLibVLC.getSpuDelay()+delta;
mLibVLC.setSpuDelay(delay);
mInfo.setText((delay/1000l)+" ms");
}
private static class ConfigureSurfaceHolder {
private final Surface surface;
private boolean configured;
......@@ -1486,6 +1563,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mDelay != DelayState.OFF){
endDelaySetting();
return true;
}
if (mDetector.onTouchEvent(event))
return true;
if (mIsLocked) {
......
/*
* *************************************************************************
* IDelayController.java
* **************************************************************************
* Copyright © 2015 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.interfaces;
public interface IDelayController {
public enum DelayState {OFF, AUDIO, SUBS};
public void showAudioDelaySetting();
public void showSubsDelaySetting();
public void endDelaySetting();
}
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