android http-live-streaming

android - download blob url video



Reproducir video m3u8 en android (6)

¿Intentaste reproducir tu enlace con el reproductor nativo directamente a través del navegador web? Si no puede reproducirlo con un reproductor nativo, significa que su archivo no es compatible con su versión actual de Android. El formato HTTP Live Streaming puede tener algunas especificidades que no son bien soportadas por Android, mientras que puede jugar en iOS.

Quiero transmitir el video en vivo y está en formato m3u8. Así que probé el siguiente código

public class StreamingPlayer extends Activity implements OnBufferingUpdateListener, OnCompletionListener, OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback{ private static final String TAG = StreamingPlayer.class.getSimpleName(); private int mVideoWidth; private int mVideoHeight; private MediaPlayer mMediaPlayer; private SurfaceView mPreview; private SurfaceHolder holder; private String path; private boolean mIsVideoSizeKnown = false; private boolean mIsVideoReadyToBePlayed = false; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.mediaplayer_2); mPreview = (SurfaceView) findViewById(R.id.surface); holder = mPreview.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } private void playVideo() { doCleanUp(); try { /* * TODO: Set path variable to progressive streamable mp4 or * 3gpp format URL. Http protocol should be used. * Mediaplayer can only play "progressive streamable * contents" which basically means: 1. the movie atom has to * precede all the media data atoms. 2. The clip has to be * reasonably interleaved. * */ path = "httplive://xboodangx.api.channel.livestream.com/3.0/playlist.m3u8"; if (path == "") { // Tell the user to provide a media file URL. Toast .makeText( this, "Please edit MediaPlayerDemo_Video Activity," + " and set the path variable to your media file URL.", Toast.LENGTH_LONG).show(); } Log.e("PATH", "Path = " + path); // Create a new media player and set the listeners mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(path); mMediaPlayer.setDisplay(holder); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepare(); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage(), e); } } public void onBufferingUpdate(MediaPlayer arg0, int percent) { Log.d(TAG, "onBufferingUpdate percent:" + percent); } public void onCompletion(MediaPlayer arg0) { Log.d(TAG, "onCompletion called"); } public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { Log.v(TAG, "onVideoSizeChanged called"); if (width == 0 || height == 0) { Log.e(TAG, "invalid video width(" + width + ") or height(" + height + ")"); return; } mIsVideoSizeKnown = true; mVideoWidth = width; mVideoHeight = height; if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) { startVideoPlayback(); } } public void onPrepared(MediaPlayer mediaplayer) { Log.d(TAG, "onPrepared called"); mIsVideoReadyToBePlayed = true; if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) { startVideoPlayback(); } } public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int k) { Log.d(TAG, "surfaceChanged called"); } public void surfaceDestroyed(SurfaceHolder surfaceholder) { Log.d(TAG, "surfaceDestroyed called"); } public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "surfaceCreated called"); playVideo(); } @Override protected void onPause() { super.onPause(); releaseMediaPlayer(); doCleanUp(); } @Override protected void onDestroy() { super.onDestroy(); releaseMediaPlayer(); doCleanUp(); } private void releaseMediaPlayer() { if (mMediaPlayer != null) { mMediaPlayer.release(); mMediaPlayer = null; } } private void doCleanUp() { mVideoWidth = 0; mVideoHeight = 0; mIsVideoReadyToBePlayed = false; mIsVideoSizeKnown = false; } private void startVideoPlayback() { Log.v(TAG, "startVideoPlayback"); holder.setFixedSize(mVideoWidth, mVideoHeight); mMediaPlayer.start(); } }

En logcat muestra el onBufferingUpdate percent:100 Pero no puedo ver el video.

El audio está funcionando pero de repente fue golpeado.

Y probé este enlace de video http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8 está funcionando. Pero el enlace de mi video no funciona y cambié httplive://... instead of http:// pero no uso.

Y vi esta respuesta también en la transmisión de video de Android mms y m3u8 .

En el enlace anterior se muestra el mensaje de video no se puede reproducir.


Creo que deberías mover esto:

mMediaPlayer.setOnPreparedListener(this);

Estar antes de la llamada a prepare()


El video fue publicado en http://www.livestream.com . En esto hay Mobile Api para streaming en vivo.

El Api es:

http://www.livestream.com/userguide/index.php?title=Mobile_API#How_to_get_mobile_compatible_clips_from_a_channel.27s_library

En el enlace de arriba hay información completa para móviles compatibles. Para obtener el enlace rtsp del canal para usar este enlace

http://xproshowcasex.channel-api.livestream-api.com/2.0/getstream

Reemplace el nombre de su canal en lugar de proshowcase . Y luego obtenga todas las direcciones URL compatibles con dispositivos móviles como iPhone, Android, Blackberry, etc.

Usando esa url puede transmitir el video en Android usando la vista de video o el reproductor de medios.

Para obtener más información, lea el enlace de Mobile Api.

Si alguien tiene el mismo problema, espero que esta respuesta te ayude.

La mejor de las suertes.


No tengo ningún problema para reproducir la transmisión:

videoView1.setVideoPath("http://***.net/livedemo/_definst_/stream3.stream/playlist.m3u8?wowzasessionid=773395207"); videoView1.start();

Sobre el mensaje:

El video no se puede reproducir

Tal vez necesite agregar permisos a su archivo Manifest:

<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


Probé el formato de video m3u8 durante más de 6 meses y no se logró. Se está reproduciendo en mi aplicación de iPhone y aplicaciones nativas. Mi servidor de transmisión es Red5 y no tiene ningún complemento RTSP. Da la transmisión RTMP y no se puede transmitir en Android. Esperé un año para obtener un sistema operativo con soporte para transmisión RTSP, pero Google no. Todavía estoy usando una vista web con un flash player para transmitir video en vivo (no tiene mucha claridad). Me siento avergonzado de decirle esto a mi cliente y continuar la búsqueda para reproducir la transmisión en vivo en el reproductor predeterminado de Android.

Creo que su url de vídeo no puede RTSP.


Cómo jugar .M3U8 Streaming en Android

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>

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)); } }); } }

He visto que muchas personas tienen problemas para jugar .M3U8, depende de los códecs utilizados para la transmisión y la compatibilidad con el dispositivo, por ejemplo, algunos de mis archivos .m3u8 solo se admiten en dispositivos con pantallas de 1200 x 800 y más.