4

I'm trying to play a m3u8 URL in the VRVideoView Sample from Google https://developers.google.com/vr/android/samples/vrview. It's working well with mp4 or flv but I have the following error when trying with m3u8 :

com.google.vr.sdk.samples.simplevideowidget E/VrVideoPlayerInternal: 136877483.onPlayerError com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.extractor.ExtractorSampleSource$UnrecognizedInputFormatException: None of the available extractors (WebmExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor) could read the stream. at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:263) at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:149) at com.google.android.exoplayer.ExoPlayerImplInternal.incrementalPrepareInternal(ExoPlayerImplInternal.java:275) at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:205) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61) at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)

Caused by: com.google.android.exoplayer.extractor.ExtractorSampleSource$UnrecognizedInputFormatException: None of the available extractors (WebmExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor) could read the stream. at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractorHolder.selectExtractor(ExtractorSampleSource.java:899) at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractingLoadable.load(ExtractorSampleSource.java:829) at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:209) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

I can see in this error stack that the Exoplayer is used to play the video, but shouldn't it work with m3u8 ? Here is the URL I used : http://www.nacentapps.com/m3u8/index.m3u8.

Thanks for your help!

Antoine
  • 583
  • 2
  • 6
  • 21
  • m3u8 is a playlist file and is not actual media file. This SO question may help: http://stackoverflow.com/questions/31418140/exoplayer-playing-m3u8-files-android – Morrison Chang Jun 09 '16 at 18:40
  • The issue I have here is that I don't directly have access to the ExoPlayer. I can only manipulate a VrVideoView object which is itself using the ExoPlayer internally. I also edited my previous message : TS files are working. – Antoine Jun 09 '16 at 20:16
  • Can't you just read the .m3u8 file, and iterate through each video passing the URL to the `VrVideoView.loadVideo(url)` method and waiting for `VrVideoEventListener.onCompleted()` before loading the next video? – Morrison Chang Jun 15 '16 at 16:03
  • did you find a solution for this? What can i do? – ovluca Nov 11 '16 at 10:57

3 Answers3

1

For playing m3u8 all you need to do is change the options input format to and it will

'Uri uri = Uri.parse("https:proper_url.m3u8");
VrVideoView.Options vrVideoView = new VrVideoView.Options(); 
vrVideoView.inputFormat = VrVideoView.Options.FORMAT_HLS; 
videoWidgetView.loadVideo(uri, vrVideoView)'
vallabh
  • 505
  • 6
  • 10
0

try replacing the url with the demo urls in the code example below, if it works, then you can reuse the example code in the github account provided below: https://github.com/google/ExoPlayer/tree/master/demo/src/main/java/com/google/android/exoplayer

if it doesn't work then the file must have some issue or exoplayer does not support it..

Manam
  • 354
  • 5
  • 16
0

To play .m3u8 file use below code while initializing Exoplayer:

Handler mHandler = new Handler();

String userAgent = Util.getUserAgent(context, "Exo Player");

DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(
                userAgent, null,
                DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                1800000,
                true);

HlsMediaSource mediaSource = new HlsMediaSource(Uri.parse(mediaUrl),dataSourceFactory, 1800000,mHandler, null);

if (mediaUrl != null) {
    videoPlayer.prepare(mediaSource);
    videoPlayer.setPlayWhenReady(true);
}
Ankit Lathiya
  • 199
  • 1
  • 12