androidx / androidx/media

HTTP 301-302 forwarding fails for .m3u8 files if extension of original is incorrect.

Open
#1,699 3 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Sep 5, 2024.

wont fix: intended behavior
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.4.1

More version details

I have also been able to reproduce this on the current 'main' branch.

Devices that reproduce the issue

Google Pixel 5 running Android Version 14.

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No

Reproduction steps

Create a new video player.
Attempt to play a video from https://c1m.co/test.php (this is my personal test server, and I'll leave the file up).
The file will return a 302 forward request to https://test-streams.mux.dev/tos_ismc/main.m3u8
Playback will fail with an error "ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED"

If you replace the URL with the final destination (https://test-streams.mux.dev/tos_ismc/main.m3u8), the video will play back just fine.

Discussion

I spent some time going through the ExoPlayer code. It appears what is happening is that after the forwarding is followed DefaultHttpDataSource, the original URL is used (...test.php) to determine the file type of the video file to play back. As it does not end with m3u8, ExoPlayer decides it must be a movie and attempts to read the binary header to determine the type of payback file.

Further, the ExoPlayer code appears to discard (or never use) the mime type returned with the forwarded file.

I have been able to work around this issue by creating a helper class that does a 'HEAD' request to get the final destination after 301/302 forwarding, as well as the returned mime type, but it seems ExoPlayer should be able to do this 'automagically.'

Expected result

The video at the URL forwarded from 'https://c1m.co/test.php' be identified correctly and played properly if it is an .m3u8 file.

Actual result

Playback will fail with an error "ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED"

Media

https://c1m.co/test.php

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.