这是什么原因?
package com.example.vv;
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
/**
* @author jren
* @parameter
* @return
*/
public class MainActivity extends Activity {
private static final String TAG = "LiveVideoPlay";
private VideoView myVideoView;
private MediaController mediaControls;
MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myVideoView = (VideoView) findViewById(R.id.videoview);
playVideo();
}
private void playVideo() {
try {
if (mediaController == null) {
mediaController = new MediaController(MainActivity.this);
}
myVideoView.setMediaController(mediaController);
String StrUri = "http://huison.oss-cn-shenzhen.aliyuncs.com/0001/huison001/live.m3u8";
Uri videoUri = Uri.parse(StrUri);
myVideoView.setVideoURI(videoUri);
myVideoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
myVideoView.start();
}
});
myVideoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
return false;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
<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"
tools:context="com.example.vv.MainActivity" >
<VideoView
android:id="@+id/videoview"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
错误:
07-14 15:14:25.872:E / MediaPlayer-JNI(25660):QCMediaPlayer媒体播放器不存在 07-14 15:14:27.872:W / MediaPlayer(25660):info / warning(801,0)