Saa*_*sha 8 android aac media-player
据我了解,Android 3.0及以上版本可以播放无线电流媒体m3u8 - http://developer.android.com/guide/appendix/media-formats.html
我把这个链接 - http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8放到MediaPlayer中但在LogCat中我得到:
06-01 09:04:44.287: INFO/LiveSession(33): onConnect 'http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8'
06-01 09:04:44.287: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio.m3u8 @0
06-01 09:04:44.747: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio.m3u8 @0
06-01 09:04:45.019: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio/ssnr_052311_071632_78731.aac @0
**06-01 09:04:45.817: ERROR/LiveSession(33): This doesn't look like a transport stream...**
06-01 09:04:45.967: INFO/HTTPLiveSource(33): input data EOS reached.
Run Code Online (Sandbox Code Playgroud)
这是我的源代码:
mp = new MediaPlayer();
start.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try {
mp.setDataSource("http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8");
mp.prepare();
mp.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
stop.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
mp.stop();
mp.reset();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
遵循此链接路径:http : //code.google.com/p/android/issues/detail? id= 14646
->
http://code.google.com/p/android/issues/detail?id=16884
->
http://code.google.com/p/android/issues/detail?id=17118
(ARGGGGH!)
最后给出答案:
基本上在Android v2.3和v3.0中,使用非标准的httplive://方案,在3.1中使用http://,但是在如何调用媒体框架中的相关方法方面有一些代码变通办法。
这是我如何在Android中播放.M3U8流的示例
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<VideoView
android:id="@+id/myVideoView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Main.java
package com.grexample.ooyalalive;
import java.net.URL;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class Main extends Activity {
private String urlStream;
private VideoView myVideoView;
private URL url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_vv);//***************
myVideoView = (VideoView)this.findViewById(R.id.myVideoView);
MediaController mc = new MediaController(this);
myVideoView.setMediaController(mc);
urlStream = "http://jorgesys.net/i/irina_delivery@117489/master.m3u8";
runOnUiThread(new Runnable() {
@Override
public void run() {
myVideoView.setVideoURI(Uri.parse(urlStream));
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
我已经看到很多人在播放.M3U8时遇到问题,这取决于用于流传输的编解码器以及与设备的兼容性,例如,某些.m3u8文件仅在屏幕1200 x800及更高的设备中受支持。
尝试使用ExoMedia,流式传输非常容易:
emVideoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4"));
Run Code Online (Sandbox Code Playgroud)
我与m3u8配合良好。
小智 4
也许你可以尝试 Vitamio 插件,http://vov.io/vitamio/
Vitamio 是一个适用于所有 Android 设备的多媒体框架。Vitamio 的工作方式类似于 Android 的默认 MediaPlayer,只不过它包含更强大的功能。而且它是完全免费的!网络协议
音视频播放支持以下网络协议:
MMS
RTSP (RTP, SDP)
HTTP progressive streaming
HTTP live streaming (M3U8), for Android 2.1+
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
56335 次 |
| 最近记录: |