我開發的應用程序,用於播放視頻..播放視頻是這裏的代碼..安卓播放寬屏視頻
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.videoview);
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
mVideoView = (VideoView)findViewById(R.id.videoview);
path=filename;
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
ViewVideo.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
mVideoView.setVideoPath(path);
mc = new MediaController(this);
mVideoView.setMediaController(mc);
mVideoView.requestFocus();
mVideoView.bringToFront();
mVideoView.start();
}
}
下面是XML代碼
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent">
</VideoView>
</RelativeLayout>
的問題是,當我嘗試播放寬屏幕16:9視頻。它在全屏顯示它,字符出現擠壓。我需要用寬屏格式(視頻上方和下方的兩個水平黑條)播放。 有什麼建議嗎?
您是否也可以發佈您的XML佈局? – theisenp
我編輯了包含xml的代碼..你能否幫我在這裏.. – Farhan
可能你需要爲VideoView設置佈局參數。我已經爲其中一個stackoverflow帖子上的視頻回放放置了一個Activty的代碼。可以參考http://stackoverflow.com/questions/6977382/videoview-in-eclipse-not-playing-on-phone/6977770#6977770 – Shash316