added tap to toggle player control
This commit is contained in:
parent
add1907ba3
commit
a4b275d5d9
|
@ -571,16 +571,18 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||||
private VideoLoader mVideoLoader;
|
private VideoLoader mVideoLoader;
|
||||||
|
|
||||||
private TextureVideoView mVideoView;
|
private TextureVideoView mVideoView;
|
||||||
|
private View mVideoViewOverlay;
|
||||||
private SeekBar mVideoViewProgress;
|
private SeekBar mVideoViewProgress;
|
||||||
private TextView mDurationLabel, mPositionLabel;
|
private TextView mDurationLabel, mPositionLabel;
|
||||||
private ImageButton mPlayPauseButton, mVolumeButton;
|
private ImageButton mPlayPauseButton, mVolumeButton;
|
||||||
|
private ProgressWheel mProgressBar;
|
||||||
|
private View mVideoControl;
|
||||||
|
|
||||||
private boolean mPlayAudio;
|
private boolean mPlayAudio;
|
||||||
private VideoPlayProgressRunnable mVideoProgressRunnable;
|
private VideoPlayProgressRunnable mVideoProgressRunnable;
|
||||||
private SaveFileTask mSaveFileTask;
|
private SaveFileTask mSaveFileTask;
|
||||||
private File mVideoFile;
|
private File mVideoFile;
|
||||||
private Pair<String, String> mVideoUrlAndType;
|
private Pair<String, String> mVideoUrlAndType;
|
||||||
private ProgressWheel mProgressBar;
|
|
||||||
private MediaPlayer mMediaPlayer;
|
private MediaPlayer mMediaPlayer;
|
||||||
|
|
||||||
public boolean isLoopEnabled() {
|
public boolean isLoopEnabled() {
|
||||||
|
@ -630,6 +632,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||||
mVideoViewProgress.setVisibility(View.VISIBLE);
|
mVideoViewProgress.setVisibility(View.VISIBLE);
|
||||||
mVideoViewProgress.post(mVideoProgressRunnable);
|
mVideoViewProgress.post(mVideoProgressRunnable);
|
||||||
updatePlayerState();
|
updatePlayerState();
|
||||||
|
mVideoControl.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,12 +661,14 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||||
public void onBaseViewCreated(View view, Bundle savedInstanceState) {
|
public void onBaseViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onBaseViewCreated(view, savedInstanceState);
|
super.onBaseViewCreated(view, savedInstanceState);
|
||||||
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
|
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
|
||||||
|
mVideoViewOverlay = view.findViewById(R.id.video_view_overlay);
|
||||||
mVideoViewProgress = (SeekBar) view.findViewById(R.id.video_view_progress);
|
mVideoViewProgress = (SeekBar) view.findViewById(R.id.video_view_progress);
|
||||||
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
|
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
|
||||||
mDurationLabel = (TextView) view.findViewById(R.id.duration_label);
|
mDurationLabel = (TextView) view.findViewById(R.id.duration_label);
|
||||||
mPositionLabel = (TextView) view.findViewById(R.id.position_label);
|
mPositionLabel = (TextView) view.findViewById(R.id.position_label);
|
||||||
mPlayPauseButton = (ImageButton) view.findViewById(R.id.play_pause_button);
|
mPlayPauseButton = (ImageButton) view.findViewById(R.id.play_pause_button);
|
||||||
mVolumeButton = (ImageButton) view.findViewById(R.id.volume_button);
|
mVolumeButton = (ImageButton) view.findViewById(R.id.volume_button);
|
||||||
|
mVideoControl = view.findViewById(R.id.video_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -723,6 +728,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||||
mDurationLabel, mPositionLabel, mVideoView);
|
mDurationLabel, mPositionLabel, mVideoView);
|
||||||
|
|
||||||
|
|
||||||
|
mVideoViewOverlay.setOnClickListener(this);
|
||||||
mVideoView.setOnPreparedListener(this);
|
mVideoView.setOnPreparedListener(this);
|
||||||
mVideoView.setOnErrorListener(this);
|
mVideoView.setOnErrorListener(this);
|
||||||
mVideoView.setOnCompletionListener(this);
|
mVideoView.setOnCompletionListener(this);
|
||||||
|
@ -796,14 +802,25 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||||
updatePlayerState();
|
updatePlayerState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case R.id.video_view_overlay: {
|
||||||
|
if (mVideoControl.getVisibility() == View.VISIBLE) {
|
||||||
|
mVideoControl.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mVideoControl.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlayerState() {
|
private void updatePlayerState() {
|
||||||
final MediaPlayer mp = mMediaPlayer;
|
final MediaPlayer mp = mMediaPlayer;
|
||||||
if (mp != null) {
|
if (mp != null) {
|
||||||
mPlayPauseButton.setImageResource(mp.isPlaying() ? R.drawable.ic_action_pause : R.drawable.ic_action_play_arrow);
|
final boolean playing = mp.isPlaying();
|
||||||
|
mPlayPauseButton.setContentDescription(getString(playing ? R.string.pause : R.string.play));
|
||||||
|
mPlayPauseButton.setImageResource(playing ? R.drawable.ic_action_pause : R.drawable.ic_action_play_arrow);
|
||||||
} else {
|
} else {
|
||||||
|
mPlayPauseButton.setContentDescription(getString(R.string.play));
|
||||||
mPlayPauseButton.setImageResource(R.drawable.ic_action_play_arrow);
|
mPlayPauseButton.setImageResource(R.drawable.ic_action_play_arrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class RecyclerViewBackport extends RecyclerView {
|
||||||
float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection();
|
float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection();
|
||||||
final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1);
|
final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1);
|
||||||
final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1);
|
final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1);
|
||||||
smoothScrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor));
|
scrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,27 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/video_view_overlay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/video_view"
|
||||||
|
android:layout_alignEnd="@+id/video_view"
|
||||||
|
android:layout_alignLeft="@+id/video_view"
|
||||||
|
android:layout_alignRight="@+id/video_view"
|
||||||
|
android:layout_alignStart="@+id/video_view"
|
||||||
|
android:layout_alignTop="@+id/video_view"
|
||||||
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/video_control"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/height_player_control_panel"
|
android:layout_height="@dimen/height_player_control_panel"
|
||||||
android:layout_alignBottom="@id/video_view"
|
android:layout_gravity="bottom"
|
||||||
android:background="@drawable/bg_shadow_video_player"
|
android:background="@drawable/bg_shadow_video_player"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/play_pause_button"
|
android:id="@+id/play_pause_button"
|
||||||
|
@ -50,6 +64,7 @@
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:contentDescription="@string/play"
|
||||||
android:minWidth="@dimen/element_size_normal"
|
android:minWidth="@dimen/element_size_normal"
|
||||||
android:src="@drawable/ic_action_play_arrow" />
|
android:src="@drawable/ic_action_play_arrow" />
|
||||||
|
|
||||||
|
@ -87,12 +102,13 @@
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:contentDescription="@string/mute"
|
||||||
android:minWidth="@dimen/element_size_normal"
|
android:minWidth="@dimen/element_size_normal"
|
||||||
android:src="@drawable/ic_action_speaker_max" />
|
android:src="@drawable/ic_action_speaker_max" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<include layout="@layout/layout_progress_wheel_medium" />
|
<include layout="@layout/layout_progress_wheel_medium" />
|
||||||
|
|
|
@ -751,4 +751,6 @@
|
||||||
<string name="comment">Comment</string>
|
<string name="comment">Comment</string>
|
||||||
<string name="enable_retweets">Enable retweets</string>
|
<string name="enable_retweets">Enable retweets</string>
|
||||||
<string name="disable_retweets">Disable retweets</string>
|
<string name="disable_retweets">Disable retweets</string>
|
||||||
|
<string name="play">Play</string>
|
||||||
|
<string name="pause">Pause</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue