WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 6 weeks ago

#31689 new defect (bug)

Media player not working with 302 redirects

Reported by: hlashbrooke Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.1.1
Component: Media Keywords: needs-testing
Focuses: Cc:

Description

When calling the audio player using wp_audio_shortcode( array( 'src' => '/path/to/file' ) ); and the path in question is a 302 redirect to an actual audio file, the audio player cannot find or play the file.

A prime example of this is with Microsoft's OneDrive - a public link to a file stored with them looks like this: https://onedrive.live.com/download?resid=###. Going to that URL ends up in a 302 redirect to the actual file. While OneDrive may not be the best way to store and share media files, it is still a valid use case. Plus, this will affect any file storage where the file is accessed via a 302 redirect.

There are alternative audio players that can handle 302 redirected files, so it's not impossible to work around the issue.

For reference, this came up in a support ticket for one of my plugins - details here: https://wordpress.org/support/topic/direct-link-to-onedrive.

Change History (2)

#1 @wonderboymusic
5 years ago

  • Component changed from Media to External Libraries

This would probably have to be fixed here: https://github.com/johndyer/mediaelement

#2 @desrosj
6 weeks ago

  • Component changed from External Libraries to Media
  • Keywords needs-testing added
  • Milestone set to Awaiting Review

I did some testing on this today. Here's what I found.

In the Classic Editor, the behavior is as follows:

  • Clicking "Add Media" and selecting "Insert from URL" leads to the file being embedded as an HTML link.
  • Inserting a [audio fileurl="urlthatisaredirect"] leads to a shortcode preview that just hangs in the loading state.

In the block editor, the behavior is as follows:

  • Inserting an audio block and clicking "Insert from URL" successfully loads the audio player with the correct track length displayed in the player. However, the audio cannot be previewed as none of the controls work. This seems to happen regardless of whether the audio block is added using a URL or by selecting an audio file in the media library. Even after the page is reloaded, I still cannot preview an audio block. Viewing the page on the front-end, the players are all usable and correctly process the 302 link.

I'm wondering if this has to do with the function calling wp_check_filetype(), which attempts to match a file type from a file name. Because the URL does not include an extension, the function is unable to accomplish that and wp_audio_shortcode() is returning without any generated HTML to display an embed.

I have not had a chance to look into how the block editor implementation is different, but the code responsible for generating the audio block preview is doing something different. I'm going to move this back to the Media component as it seems something is going on with the shortcode or media related code and not the MediaElement.js code.

Note: See TracTickets for help on using tickets.