您顯示的錄製代碼似乎是正確的。我只是用ICS測試了我的三星S2上的代碼,並且視頻以正確的方向播放。 您不顯示播放的代碼。也許這就是問題所在:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 120) { // i personally prefer using a constant here
VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setVideoURI(data.getData());
videoView.start();
}
}
爲videoView佈局XML是非常簡單的:
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
如果以上不工作,你也可以嘗試EXTRA_SCREEN_ORIENTATION設置爲不同的值。儘管YMMV,但在我的設備上它似乎沒有什麼區別。下面的代碼,再加上我在一些額外扔,因爲你已經要求更多的自定義視頻記錄代碼:
private static final int RECORD_VIDEO = 120;
private void startRecording() {
Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
cameraIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // low quality
cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 5); // limit to 5 seconds
startActivityForResult(cameraIntent, RECORD_VIDEO);
}
有很多更演員:http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_DURATION_LIMIT
你能給示例代碼,如果您有它。我沒有聽到你說的話,當我試着按照你所說的仍然遇到問題時。 – TNR 2013-02-21 06:10:14
我說它可能只是一個小問題,因爲你的代碼運行正常。使用Ctrl + F11交替模擬器的方向,查看它是否適用於橫向或縱向。 – user1978601 2013-03-03 23:42:27