Skip to content

Commit

Permalink
Add video mode demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Crossle Song committed Aug 27, 2013
1 parent 7920cb2 commit 6163853
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion vitamio-sample/res/layout/subtitle2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:text="@string/res_audio" />
android:text="@string/res_audio" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/sub1"
android:background="@drawable/mediacontroller_sreen_size_100"
android:onClick="changeLayout" />

</RelativeLayout>
50 changes: 48 additions & 2 deletions vitamio-sample/src/io/vov/vitamio/demo/VideoViewSubtitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -33,6 +34,8 @@ public class VideoViewSubtitle extends Activity {
private String subtitle_path = "";
private VideoView mVideoView;
private TextView mSubtitleView;
private long mPosition = 0;
private int mVideoLayout = 0;

@Override
public void onCreate(Bundle icicle) {
Expand All @@ -41,7 +44,6 @@ public void onCreate(Bundle icicle) {
return;
setContentView(R.layout.subtitle2);
mVideoView = (VideoView) findViewById(R.id.surface_view);

mSubtitleView = (TextView) findViewById(R.id.subtitle_view);

if (path == "") {
Expand Down Expand Up @@ -77,10 +79,54 @@ public void onTimedText(String text) {

@Override
public void onTimedTextUpdate(byte[] pixels, int width, int height) {

}
});
}
}

@Override
protected void onPause() {
mPosition = mVideoView.getCurrentPosition();
mVideoView.stopPlayback();
super.onPause();
}

@Override
protected void onResume() {
if (mPosition > 0) {
mVideoView.seekTo(mPosition);
mPosition = 0;
}
super.onResume();
mVideoView.start();
}

public void changeLayout(View view) {
mVideoLayout++;
if (mVideoLayout == 4) {
mVideoLayout = 0;
}
switch (mVideoLayout) {
case 0:
mVideoLayout = VideoView.VIDEO_LAYOUT_ORIGIN;
view.setBackgroundResource(R.drawable.mediacontroller_sreen_size_100);
break;
case 1:
mVideoLayout = VideoView.VIDEO_LAYOUT_SCALE;
view.setBackgroundResource(R.drawable.mediacontroller_screen_fit);
break;
case 2:
mVideoLayout = VideoView.VIDEO_LAYOUT_STRETCH;
view.setBackgroundResource(R.drawable.mediacontroller_screen_size);
break;
case 3:
mVideoLayout = VideoView.VIDEO_LAYOUT_ZOOM;
view.setBackgroundResource(R.drawable.mediacontroller_sreen_size_crop);

break;
}
mVideoView.setVideoLayout(mVideoLayout, 0);
}

}

0 comments on commit 6163853

Please sign in to comment.