简体   繁体   中英

java Code : how to stream live channels in android to watch live

I am trying to build an app that will make live channel broadcasting like there are many apps that belongs to CNN, BBC , NatGEO for live tv. i dont know whether its a correct way or not. what i am doing i am just placing URL= http://live.express.pk/ but i get IOExceptional error.

error:

setDataSource: IOException! uri= "http://live.express.pk/" 

you can see through image link:

enter image description here

I have placed Vitamio library from Github. Here is the code:

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 manifestfile: 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>

use vitamio library to stream live tv channels.. download from git hub. https://github.com/yixia/VitamioBundle ?

u can use :

 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

For all kind of streams :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM