Ported media control buttons to landscape video player
This commit is contained in:
parent
3931244c35
commit
b291d56fbb
@ -3,49 +3,93 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/videoview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
<!-- Mediaplayer controls -->
|
||||
android:id="@+id/videoview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<!-- Mediaplayer controls -->
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/playercontrols"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:background="@color/gray" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPosition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/position_default_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvLength"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/position_default_label"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sbPosition"
|
||||
<LinearLayout
|
||||
android:id="@+id/overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0px"
|
||||
android:layout_toLeftOf="@id/txtvLength"
|
||||
android:layout_toRightOf="@id/txtvPosition"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:max="500" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
android:layout_gravity="bottom|center"
|
||||
android:alpha="0"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/playercontrol"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="clip_horizontal"
|
||||
android:layout_margin="4dp" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butPlay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/borderless_button"
|
||||
android:src="@android:drawable/ic_media_pause" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butFF"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_toRightOf="@+id/butPlay"
|
||||
android:background="@drawable/borderless_button"
|
||||
android:src="@android:drawable/ic_media_ff" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butRev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@+id/butPlay"
|
||||
android:background="@drawable/borderless_button"
|
||||
android:src="@android:drawable/ic_media_rew" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/timecontrol"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginBottom="4dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPosition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/position_default_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvLength"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/position_default_label" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sbPosition"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@+id/txtvLength"
|
||||
android:layout_toRightOf="@+id/txtvPosition"
|
||||
android:max="500" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@ -116,7 +116,7 @@ public class MediaplayerActivity extends SherlockActivity implements
|
||||
setContentView(R.layout.mediaplayer_activity);
|
||||
}
|
||||
setupGUI();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -187,17 +187,13 @@ public class MediaplayerActivity extends SherlockActivity implements
|
||||
positionObserver.cancel(true);
|
||||
positionObserver = null;
|
||||
}
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_play);
|
||||
}
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_play);
|
||||
break;
|
||||
case PLAYING:
|
||||
setStatusMsg(R.string.player_playing_msg, View.INVISIBLE);
|
||||
loadMediaInfo();
|
||||
setupPositionObserver();
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_pause);
|
||||
}
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_pause);
|
||||
break;
|
||||
case PREPARING:
|
||||
setStatusMsg(R.string.player_preparing_msg, View.VISIBLE);
|
||||
@ -209,9 +205,7 @@ public class MediaplayerActivity extends SherlockActivity implements
|
||||
case PREPARED:
|
||||
loadMediaInfo();
|
||||
setStatusMsg(R.string.player_ready_msg, View.VISIBLE);
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_play);
|
||||
}
|
||||
butPlay.setImageResource(android.R.drawable.ic_media_play);
|
||||
break;
|
||||
case SEEKING:
|
||||
setStatusMsg(R.string.player_seeking_msg, View.VISIBLE);
|
||||
@ -289,6 +283,9 @@ public class MediaplayerActivity extends SherlockActivity implements
|
||||
sbPosition = (SeekBar) findViewById(R.id.sbPosition);
|
||||
txtvPosition = (TextView) findViewById(R.id.txtvPosition);
|
||||
txtvLength = (TextView) findViewById(R.id.txtvLength);
|
||||
butPlay = (ImageButton) findViewById(R.id.butPlay);
|
||||
butRev = (ImageButton) findViewById(R.id.butRev);
|
||||
butFF = (ImageButton) findViewById(R.id.butFF);
|
||||
|
||||
sbPosition.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
int duration;
|
||||
@ -322,34 +319,32 @@ public class MediaplayerActivity extends SherlockActivity implements
|
||||
}
|
||||
});
|
||||
|
||||
butPlay.setOnClickListener(playbuttonListener);
|
||||
|
||||
butFF.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status == PlayerStatus.PLAYING) {
|
||||
playbackService.seekDelta(DEFAULT_SEEK_DELTA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
butRev.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status == PlayerStatus.PLAYING) {
|
||||
playbackService.seekDelta(-DEFAULT_SEEK_DELTA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
imgvCover = (ImageView) findViewById(R.id.imgvCover);
|
||||
txtvStatus = (TextView) findViewById(R.id.txtvStatus);
|
||||
butPlay = (ImageButton) findViewById(R.id.butPlay);
|
||||
butRev = (ImageButton) findViewById(R.id.butRev);
|
||||
butFF = (ImageButton) findViewById(R.id.butFF);
|
||||
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
|
||||
txtvFeed = (TextView) findViewById(R.id.txtvFeed);
|
||||
|
||||
butPlay.setOnClickListener(playbuttonListener);
|
||||
|
||||
butFF.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status == PlayerStatus.PLAYING) {
|
||||
playbackService.seekDelta(DEFAULT_SEEK_DELTA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
butRev.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status == PlayerStatus.PLAYING) {
|
||||
playbackService.seekDelta(-DEFAULT_SEEK_DELTA);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setTheme(R.style.Theme_Sherlock_Light_NoActionBar);
|
||||
videoview = (VideoView) findViewById(R.id.videoview);
|
||||
|
Loading…
x
Reference in New Issue
Block a user