Hello
Die Klasse
String link="http://www.hc-linux.eu/javatechdemo/JavaTechDemo.mp4";
Uri uriVideoPath = Uri.parse(link);
public void getInit() {
video_player_view = (VideoView) findViewById(R.id.videoView1);
media_Controller = new MediaController(this);
dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);
int height = dm.heightPixels;
int width = dm.widthPixels;
video_player_view.setMinimumWidth(width);
video_player_view.setMinimumHeight(height);
video_player_view.setMediaController(media_Controller);
video_player_view.setVideoURI(link);
video_player_view.start();
}
XML
[XML]
<RelativeLayout xmlns:android=„http://schemas.android.com/apk/res/android“
xmlns:tools=„http://schemas.android.com/tools“
android:layout_width=„match_parent“
android:layout_height=„match_parent“
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="eu.success.Tutorial" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
Die getInit() rufe ich so auf
[/XML]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tutorial);
getInit();
}
Beim starten popt eine Fehlermeldung aus: Video kann nicht wiedergegeben werden
Die Exception
11-28 18:31:31.505: D/MediaPlayer(7063): Couldn’t open file on client side, trying server side
11-28 18:31:31.505: E/MediaPlayer(7063): Unable to create media player
11-28 18:31:31.510: W/VideoView(7063): Unable to open content: http://www.hc-linux.eu/javatechdemo/JavaTechDemo.mp4
11-28 18:31:31.510: W/VideoView(7063): java.io.IOException: setDataSource failed.: status=0x80000000
11-28 18:31:31.510: W/VideoView(7063): at android.media.MediaPlayer._setDataSource(Native Method)
11-28 18:31:31.510: W/VideoView(7063): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:991)
11-28 18:31:31.510: W/VideoView(7063): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:972)