3

I have an app with a VideoView to display an MP4 file. Everything was working perfectly fine, on all devices and all Android versions, until Android 12.

We have one user reporting that the VideoView is unable to play the videos, for every video he gets the following popup (the app doesn't crash, just this popup is shown):

Can't play video Error on Android 12

My question: does anyone know what the problem might be? I'm expecting - or hoping - it has to do with the fact that it's the beta version of Android 12. If that's not the case, then how can I solve this issue? Anything that changed for Android 12 w.r.t. displaying videos?

Many thanks.

EDIT: The video files are located in local storage (R.raw folder)

EDIT 2: When running the emulator with Android 12, I get the MediaPlyaer error (1, -2147483648). This corresponds to MediaPlayer.MEDIA_ERROR_UNKNOWN and UNKNOWN_ERROR respectively, as explained in this SO post. However, the proposed solutions there don't solve the problem here (the format should not be the issue, since they are .mp4 files). Any ideas?

EDIT 3: I submitted an issue with Google about this. If you're interested in a solution, star it here. Hope we can find the cause soon!

Jorn Rigter
  • 745
  • 1
  • 6
  • 25
  • Is there anything relevant at [https://developer.android.com/about/versions/12](https://developer.android.com/about/versions/12)? – Markus Kauppinen Jul 09 '21 at 12:39
  • 1
    Where your videos are located? Maybe it's have a connection to the whole MANAGE_EXTERNAL_STORAGE permission from android 11+ – Nirel Jul 09 '21 at 12:49
  • @MarkusKauppinen I couldn't find anything relevant unfortunately.. – Jorn Rigter Jul 09 '21 at 12:54
  • @Nirel they are located in the R.raw folder, so not in external storage (also, videos were still working on Android 11) – Jorn Rigter Jul 09 '21 at 12:54
  • Ok, maybe you should try create your own android emulator and run it... – Nirel Jul 09 '21 at 13:01
  • is it an in-app resource or local storage located video? – Hossein Kurd Nov 09 '21 at 08:43
  • 1
    It's local storage (in R.raw) – Jorn Rigter Nov 09 '21 at 10:15
  • I've seen that videos without the AAC codec won't play in my app. What codecs does your video have? (go to file -> get info) – em_ Nov 24 '21 at 05:01
  • @ElliotM The codes is AVC (Advanced Video Coding). The [supported video formats](https://stuff.mit.edu/afs/sipb/project/android/docs/guide/appendix/media-formats.html) states that this AVC codec should be working. Are you talking about the audio encoding, or the video encoding? – Jorn Rigter Nov 24 '21 at 10:00

1 Answers1

1

What fixed it was saving the video in AVC/H264 format and using that file.

From reporting this issue on Google's Issuetracker here, it turned out that the problem was actually with the encoding of the video files in this case. The video that wasn't playing was encoded in MPEG-4 format (.mp4) and exceeded the capabilities of the MPEG-4 software decoder.

I don't know why this wasn't an issue before Android 12 (videos were playing fine before), but at least this does fix the issue.

Jorn Rigter
  • 745
  • 1
  • 6
  • 25