google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.75k stars 6.03k forks source link

Do not get a preview, prepare and play do not work properly. Cautch exceptopns until press a play button #10532

Open EkaterinaT89 opened 2 years ago

EkaterinaT89 commented 2 years ago

ExoPlayer Version

2.18.1

Devices that reproduce the issue

Pisel 3 running Android 9 - emulyator

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

  1. Open camera by cameraX
  2. Record some video
  3. Play stop button
  4. Open videopreviewfragment
  5. Init player

Expected result

We do can see preview of our video from camera

Actual result

We do NOT can see preview of our video from camera. Cautch this exeptions:

E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: Source error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException
        at com.google.android.exoplayer2.upstream.FileDataSource.open(FileDataSource.java:121)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
E/EventLogger: internalError [eventTime=0.22, mediaPos=0.00, window=0, period=0, loadError
      com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException
        at com.google.android.exoplayer2.upstream.FileDataSource.open(FileDataSource.java:121)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
    ]
E/EventLogger: playerFailed [eventTime=0.24, mediaPos=0.00, window=0, period=0, errorCode=ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE
      com.google.android.exoplayer2.ExoPlaybackException: Source error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException
        at com.google.android.exoplayer2.upstream.FileDataSource.open(FileDataSource.java:121)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
}

However we can watch a video after press a play button. I tried to call prepare(), play(), playwhenprepare = true.

Media

Video from cameraX on the phone.

Bug Report

marcbaechinger commented 2 years ago

The exception is originated by the open method of the FileDataSource that reports that the remaining bytes to read is smaller than 0.

The report says, that this is happening on an emulator. To be honest, I don't know what CamaraX is recording on an emulator and what is stored in the path with that you created the PrgressiveMediaSource. Can you as a first step repro this on an real device and see whether this fails in the same way?

If it does repro on a real device in the same way, can you check what is in this file that is stored on the file system, whether it actually exists and what it contains? If you can then attach the file here on the issue we can do some further investigations.

In any case, I suspect this is rather an issue with CameraX (probably specifically on an emulator) and producing the media and not with ExoPlayer playback. That's why it would be interesting to get the file, because then we can see whether this it is a vaild file and we can continue investigating the playback failure on our end.