Android直播电视直播

时间:2014-01-28 16:42:31

标签: android http-live-streaming

此应用程序适用于直播电视流媒体。当我运行它时,它说"抱歉这个视频无法播放"。

以下是活动:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    VideoView player = (VideoView)findViewById(R.id.player);
    String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8";
    //for Android 2.3.3 I used httplive:// prefix
    player.setVideoURI(Uri.parse(httpLiveUrl));
    player.setMediaController(new MediaController(this));
    player.requestFocus();
    player.start();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

这是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" >

<VideoView
android:id="@+id/player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>

这是logcat: enter image description here

请帮帮我。

1 个答案:

答案 0 :(得分:0)

将此权限添加到AndroidManifest.xml文件中:

<uses-permission android:name="android.permission.INTERNET" />