我正试图建立一个应用程序,将使直播频道广播,就像有许多应用程序属于CNN, BBC, NatGEO的直播电视。我不知道这是不是正确的方法。我正在做什么,我只是放置URL= http://live.express.pk/,但我得到ioexception错误。
错误:setDataSource: IOException! uri= "http://live.express.pk/"
你可以通过图片链接看到:
输入图片描述
我已经把Vitamio库从Github。下面是代码:
VideoStreamActivity.java:
package com.tutorial.streaming;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class VideoStreamActivity extends Activity {
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in= new Intent(VideoStreamActivity.this, Show.class);
startActivity(in);
}
});
}
@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;
}
}
My Manifest file: Videostream Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tutorial.streaming"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.tutorial.streaming.VideoStreamActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Show">
</activity>
</application>
</manifest>
使用vitamio库直播电视频道。从git hub下载。https://github.com/yixia/VitamioBundle?
你可以使用:
implementation 'com.devbrackets.android:exomedia:4.0.3' //TV
implementation 'com.google.android.exoplayer:exoplayer:r2.4.3' //TV & Radio
implementation 'com.cleveroad:audiovisualization:1.0.0' //Radio