0
여기 비디오를 재생하는 코드입니다. 그러나 비디오는 내 화면에 그대로 있으며 재생되지 않습니다. 어떤 해결책이 있습니까?비디오는 재생되지 않지만 오디오는 듣기
여기 비디오를 재생하는 코드입니다. 그러나 비디오는 내 화면에 그대로 있으며 재생되지 않습니다. 어떤 해결책이 있습니까?비디오는 재생되지 않지만 오디오는 듣기
video_player_view.xml
<?xml version="1.0" encoding="utf-8"?>
<VideoView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/VideoPlayerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Java code:
public class VideoPlayerActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player_view);
String video_file_path = ?;//give the path of your video
VideoView video_view = (VideoView) this.findViewById(R.id.VideoPlayerView);
MediaController mc = new MediaController(this);
video_view.setMediaController(mc);
video_view.setVideoPath(video_file_path);
video_view.requestFocus();
// start video
video_view.start();
video_view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
endActivity();
}
});
}
public void endActivity() {
this.finish();
}
}
왜이 코드를 사용하고 있습니까?
Intent tostart = new Intent(Intent.ACTION_VIEW);
startActivity(tostart);
동영상을 소리와 함께 재생할 필요가없는 경우 제거하십시오. 그렇지 않으면 비디오 재생과 정확히하고 싶은 것을 적어주십시오.