我遇到了大麻烦,我无法在我的安卓视频视图中播放 m3u8 文件,但在 iPhone 中很容易。我用谷歌搜索并访问了几个论坛,所有人都说这是不可能的。但我尝试了 vitamio(http://vov.io/vitamio/),它可以流式传输 5 到 6 秒。那是有机会流式传输,但是如何?
如果安卓中的 m3u8 流媒体很难,如何从 IP摄像机流式传输到我的安卓设备?
如果有人知道这件事,请给予回应,我非常感谢您的回复,因为我为此花费了更多的时间。
我尝试过Android版本为2.1,2.2,2.3,2.3.6和4.0的设备。vitamio 应用程序可以在所有设备中流式传输 url 5 到 6 秒,除了具有 android 版本 4.0 的设备 HTC onex。
下面给出了我调用简单 m3u8 url 的代码。非常感谢约克。
活动:
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();
}
}
}
布局:
<?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>
谢谢