我尝试使用 videoview lib 在我的 nexus 7(android 4.2)上流式传输视频,但是当我启动应用程序时,我的 nexus 7 显示“无法播放此视频”,希望您能提供帮助。我的源代码:
package com.test.prog;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.VideoView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Uri viduri=Uri.parse("http://www.law.duke.edu/cspd/contest/finalists/viewentry.php?file=docandyou");
VideoView video=(VideoView)findViewById(R.id.videoview);
video.setVideoURI(viduri);
}
}
和布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity" >
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
/>
</RelativeLayout>
LogCat 说:
11-19 17:46:08.504: D/VideoView(16804): Error: 1,0
11-19 17:46:19.504: D/MediaPlayer(16804): Couldn't open file on client side, trying server side
11-19 17:46:19.504: E/MediaPlayer(16804): Unable to to create media player
问候基督徒