Reproducir vídeo m3u8 en android

Quiero vivir transmitiendo el video y está en formato m3u8. Así que probé el código a continuación

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 onBufferingUpdate percent:100 Pero no puedo ver el video.

El audio está funcionando pero de repente fue golpeado.

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

Y vi esta respuesta también Android mms de flujo de vídeo y m3u8 .

En el enlace anterior muestra El mensaje no se puede reproducir.

El video existía en http://www.livestream.com . En esto hay Api móvil para la transmisión 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 anterior hay información completa para móviles compatibles. Para obtener el enlace rtsp desde el 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 obtener todos los móviles compatibles url como IPhone, Android, Blackberry, etc,

Usando esa url puedes transmitir el video en Android usando la vista de video o reproductor multimedia.

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

Si alguien consigue el mismo problema espero que esta respuesta le ayude.

La mejor de las suertes.

No tengo ningún problema para reproducir stream:

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

Sobre el mensaje:

El video no se puede reproducir

Quizás necesite agregar permisos a su archivo de manifiesto:

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

Creo que deberías mover esto:

 mMediaPlayer.setOnPreparedListener(this); 

Estar antes del llamado a prepare()

¿Has intentado 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 la versión de Android actual. HTTP Live Streaming formato puede tener algunas especificidades que no son bien soportados por Android, mientras que puede jugar en IOS.

He intentado el formato video m3u8 por más de 6 meses y no se logra. Se reproduce en mi aplicación de iPhone y aplicaciones nativas. Mi servidor de streaming es Red5 y no tiene ningún complemento RTSP. Da RTMP streaming y no se puede transmitir en Android. Esperé un año para obtener un sistema operativo con soporte para streaming RTSP, pero google no lo han hecho. Aún estoy usando una vista web con un reproductor flash para transmitir video en vivo (no tiene mucha claridad). Siento vergüenza de decir esto a mi cliente y continuar la búsqueda para reproducir la transmisión en vivo en el reproductor por defecto de Android.

Creo que su URL de video no puede RTSP.

Cómo jugar .M3U8 Streaming in 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 a mucha gente tener problemas para reproducir .M3U8, depende de los codecs utilizados para la transmisión y compatibilidad con el dispositivo, por ejemplo, algunos de mis archivos .m3u8 sólo son compatibles en dispositivos con pantallas de 1200 x 800 y superior.

  • Android HLS Streaming - Diferentes versiones de Android cargan ubicación diferente en Stream
  • ¿Por qué se tarda más tiempo en que algunas corrientes de audio en Internet comiencen a reproducirse en un Samsung S3?
  • Tamaño de la memoria intermedia de Android VideoView
  • Transmisión de vídeo en directo desde el dispositivo Android al servidor
  • Desarrolla reproductor de video en android para apoyar HLS
  • Metadatos temporizados para la transmisión HTTP en tiempo real en android
  • Transmisión en directo a través de mediaplayer en android
  • Obtener la fecha actual en Http Live Streaming Android 3.0+
  • Tipo de video mime de Android HLS
  • Soporte Android Widevine HLS / DRM
  • ¿Reproductor de vídeo flotante en android?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.