Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Android include webView cookies for streaming in setDataSource() #346

Open
pvandrunen opened this issue Jun 15, 2022 · 0 comments
Open

Comments

@pvandrunen
Copy link

Feature Request

Motivation Behind Feature

On Android I am unable to stream mp3 files that require authentication header to access.

I've set this as a feature because it looks like it was never intentionally implemented, HOWEVER, it might be a bug if other users are not experiencing this problem.

Note: I am using Capacitor.

Feature Description

The media.create function would include an additional boolean parameter to indicate whether the streaming file should include headers, or an array of headers to include.

AFAICT this is only a problem on Android. I'm surprised that this doesn't work or hasn't been implemented so maybe I'm doing something wrong:

Using the cordova-plugin-filetransfer I am able to download files that require authentication. When I look at the Java code I see there is a function that pulls the cookie's from webview and includes them in the header with the file request.

When I look at the Java code for cordova-plugin-media I see this, which does not include any headers
if (this.isStreaming(file)) { this.player.setDataSource(file);

And looking at the API for setDataSource, it looks like I can include the headers. But it also says that they might already be managed by the apps own CookieManager.
https://developer.android.com/reference/android/media/MediaPlayer#setDataSource(android.content.Context,%20android.net.Uri,%20java.util.Map%3Cjava.lang.String,%20java.lang.String%3E,%20java.util.List%3Cjava.net.HttpCookie%3E)

Alternatives or Workarounds

  • I am able to playback files that do not require authentication.
  • I am able to download with fileTransfer files that require authentication.
  • I could download the files before playing them back. But that's not a great experience.
  • I could also add an endpoint to the API to create a token for the file url to authenticate that way, but that would be fairly involved as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant