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 TextureVideoView mVideoView;
|
||||
private View mVideoViewOverlay;
|
||||
private SeekBar mVideoViewProgress;
|
||||
private TextView mDurationLabel, mPositionLabel;
|
||||
private ImageButton mPlayPauseButton, mVolumeButton;
|
||||
private ProgressWheel mProgressBar;
|
||||
private View mVideoControl;
|
||||
|
||||
private boolean mPlayAudio;
|
||||
private VideoPlayProgressRunnable mVideoProgressRunnable;
|
||||
private SaveFileTask mSaveFileTask;
|
||||
private File mVideoFile;
|
||||
private Pair<String, String> mVideoUrlAndType;
|
||||
private ProgressWheel mProgressBar;
|
||||
private MediaPlayer mMediaPlayer;
|
||||
|
||||
public boolean isLoopEnabled() {
|
||||
|
@ -630,6 +632,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
mVideoViewProgress.setVisibility(View.VISIBLE);
|
||||
mVideoViewProgress.post(mVideoProgressRunnable);
|
||||
updatePlayerState();
|
||||
mVideoControl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,12 +661,14 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
public void onBaseViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
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);
|
||||
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
|
||||
mDurationLabel = (TextView) view.findViewById(R.id.duration_label);
|
||||
mPositionLabel = (TextView) view.findViewById(R.id.position_label);
|
||||
mPlayPauseButton = (ImageButton) view.findViewById(R.id.play_pause_button);
|
||||
mVolumeButton = (ImageButton) view.findViewById(R.id.volume_button);
|
||||
mVideoControl = view.findViewById(R.id.video_control);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -723,6 +728,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
mDurationLabel, mPositionLabel, mVideoView);
|
||||
|
||||
|
||||
mVideoViewOverlay.setOnClickListener(this);
|
||||
mVideoView.setOnPreparedListener(this);
|
||||
mVideoView.setOnErrorListener(this);
|
||||
mVideoView.setOnCompletionListener(this);
|
||||
|
@ -796,14 +802,25 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
updatePlayerState();
|
||||
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() {
|
||||
final MediaPlayer mp = mMediaPlayer;
|
||||
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 {
|
||||
mPlayPauseButton.setContentDescription(getString(R.string.play));
|
||||
mPlayPauseButton.setImageResource(R.drawable.ic_action_play_arrow);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class RecyclerViewBackport extends RecyclerView {
|
|||
float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection();
|
||||
final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1);
|
||||
final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1);
|
||||
smoothScrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor));
|
||||
scrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,64 +35,80 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/video_view_overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_player_control_panel"
|
||||
android:layout_alignBottom="@id/video_view"
|
||||
android:background="@drawable/bg_shadow_video_player"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
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">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/play_pause_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:src="@drawable/ic_action_play_arrow" />
|
||||
<LinearLayout
|
||||
android:id="@+id/video_control"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_player_control_panel"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_shadow_video_player"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/position_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="12:34" />
|
||||
<ImageButton
|
||||
android:id="@+id/play_pause_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/play"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:src="@drawable/ic_action_play_arrow" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/video_view_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
<TextView
|
||||
android:id="@+id/position_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="12:34" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="27:56" />
|
||||
<SeekBar
|
||||
android:id="@+id/video_view_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="27:56" />
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/volume_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:src="@drawable/ic_action_speaker_max" />
|
||||
<ImageButton
|
||||
android:id="@+id/volume_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/mute"
|
||||
android:minWidth="@dimen/element_size_normal"
|
||||
android:src="@drawable/ic_action_speaker_max" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/layout_progress_wheel_medium" />
|
||||
|
|
|
@ -751,4 +751,6 @@
|
|||
<string name="comment">Comment</string>
|
||||
<string name="enable_retweets">Enable retweets</string>
|
||||
<string name="disable_retweets">Disable retweets</string>
|
||||
<string name="play">Play</string>
|
||||
<string name="pause">Pause</string>
|
||||
</resources>
|
Loading…
Reference in New Issue