首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android视频直播

Android视频直播
EN

Stack Overflow用户
提问于 2012-05-02 12:42:11
回答 1查看 5.4K关注 0票数 0

我有大麻烦了,我不能在我的安卓videoview中播放m3u8文件,但在iPhone中它是如此简单。我在谷歌上搜索并访问了几个论坛,都说这是不可能的。但我试过vitamio(http://vov.io/vitamio/),它可以流媒体5到6秒。这是一个流媒体的机会,但如何呢?

如果android中的m3u8流媒体很难,如何从IPcamera流媒体到我的android设备?

如果有人知道这件事,请给我回复,我非常感谢你的回复,因为我为此花费了更多的时间。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-11 15:46:29

我试过安卓2.1、2.2、2.3、2.3.6和4.0版本的设备。vitamio应用程序可以在除具有android版本4.0的设备HTC onex之外的所有设备中流式传输url 5到6秒。

我调用简单m3u8 url的代码如下所示。非常感谢你。

活动:

代码语言:javascript
复制
       package com.livestrean;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class streamplayer extends Activity {
    /** Called when the activity is first created. */


     private String path = "An m3u8 Url";


     private VideoView mVideoView;




    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try
        {
            setContentView(R.layout.surface_view_1);
            mVideoView = (VideoView) findViewById(R.id.surface_view);

                mVideoView.setVideoURI(Uri.parse(path));                
                mVideoView.setMediaController(new MediaController(this));
                mVideoView.requestFocus();              
                mVideoView.postInvalidateDelayed(100);        
                mVideoView.start();



        }catch (Exception e) {

            Toast.makeText(streamplayer.this,"Error Occured:- " + e.getMessage(),Toast.LENGTH_SHORT).show();
        } 
    }
}

布局:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <VideoView 
        android:id="@+id/surface_view" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"/>

</LinearLayout>

谢谢

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10407833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档