stream live video to Android
Asked Answered
I

4

21

How can I stream live video to Android (2.1 and higher), I have two links: m3u8 and f4m (As I know, f4m is not supported).

From what I saw on stackoverflow, there is a way to stream m3u8 with vitamio (but the link is not working ).

Is there any other way to stream m3u8 video ? Maybe there is other format that I can use ?

Thanks.

Intine answered 10/8, 2012 at 9:15 Comment(0)
I
37

Because no one answered my question, I will do it myself.

If you want to perform HLT (HTTP Live Stream) on Android 2.1 and higher you may use the vitamio library.

Site at: (http://www.vitamio.org/).

Here is code example: The main layout:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/LinearLayout01"
            android:layout_height="fill_parent"         xmlns:android="http://schemas.android.com/apk/res/android"
            android:paddingLeft="2px" android:paddingRight="2px"
            android:paddingTop="2px" android:paddingBottom="2px"
            android:layout_width="fill_parent" android:orientation="vertical">

            <io.vov.vitamio.widget.VideoView
                 android:layout_height="fill_parent"
                 android:layout_width="fill_parent" android:id="@+id/VideoView">               
            </io.vov.vitamio.widget.VideoView>
</LinearLayout>

the Class:

import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;



public class LiveStrimingTestActivity extends Activity{

    VideoView videoView;

    private void test_2(){
        String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8";   
        videoView = (VideoView) findViewById(R.id.VideoView);
        videoView.setVideoURI(Uri.parse(httpLiveUrl));
        MediaController mediaController = new MediaController(this);
        videoView.setMediaController(mediaController);
        videoView.requestFocus();
        videoView.start();
    }


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        test_2();             
    }     
}
Intine answered 11/8, 2012 at 7:46 Comment(1)
Please check below before you add this library in your project on api level 23. github.com/yixia/VitamioBundle/issues/…Depilate
B
4

I have tested the same stream on devices with OS 2.2, 2.3.4 and 4.0.4. This stream plays very well with regular VideoView on the devices I have got. I dont use MediaController with live streams. The rest of the code is simple.

initializeVideoView();
mVideoView.setVideoURI(Uri.parse("http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8"));
mVideoView.setMediaController(null);
mVideoView.start(); 
Bascomb answered 28/8, 2012 at 10:26 Comment(0)
B
0

KickFlip is an open source and free library for Video Streaming and it is super easy t setup.

Kickflip.initWithApiKey(API_KEY, API_SECRET);
Kickflip.startBroadcastActivity(this, mBroadcastListener);

try this.

Bucci answered 19/9, 2017 at 9:5 Comment(0)
M
0

To add vitamio to your project just add this dependency. compile 'me.neavo:vitamio:4.2.2' and then as @butter told you to do. Happy Coding.good luck

Mabe answered 20/2, 2018 at 9:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.