简体   繁体   English

将实时视频流式传输到Android

[英]stream live video to Android

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). 如何将实时视频流式传输到Android(2.1及更高版本),我有两个链接: m3u8f4m (据我所知,不支持f4m)。

From what I saw on stackoverflow, there is a way to stream m3u8 with vitamio (but the link is not working ). 从我在stackoverflow上看到的,有一种方法可以使用vitamio来传输m3u8(但链接不起作用)。

Is there any other way to stream m3u8 video ? 有没有其他方法来传输m3u8视频? Maybe there is other format that I can use ? 也许我还可以使用其他格式?

Thanks. 谢谢。

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. 如果您想在Android 2.1及更高版本上执行HLT(HTTP Live Stream),您可以使用vitamio库。

Site at: ( http://www.vitamio.org/ ). 网址:( 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();             
    }     
}

I have tested the same stream on devices with OS 2.2, 2.3.4 and 4.0.4. 我在OS 2.2,2.3.4和4.0.4的设备上测试了相同的流。 This stream plays very well with regular VideoView on the devices I have got. 这个流与我所拥有的设备上的常规VideoView非常相配。 I dont use MediaController with live streams. 我不使用MediaController和实时流。 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(); 

KickFlip is an open source and free library for Video Streaming and it is super easy t setup. KickFlip是一个开源和免费的视频流库,它非常容易设置。

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

try this. 试试这个。

To add vitamio to your project just add this dependency. 要为项目添加vitamio,只需添加此依赖项。 compile 'me.neavo:vitamio:4.2.2' and then as @butter told you to do. 编译'me.neavo:vitamio:4.2.2',然后@butter告诉你这样做。 Happy Coding.good luck 快乐的Coding.good运气

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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