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

Added optional additional headers to createPlayer config for FetchStreamLoader #372

Merged
merged 3 commits into from
Sep 20, 2018

Conversation

yyyar
Copy link
Contributor

@yyyar yyyar commented Sep 12, 2018

Hello! First of all, thanks for the awesome library!

This PR adds additional optional headers to createPlayer config for use in FetchStreamLoader.
For example, it is needed to specify 'Authorization' Basic Auth header to allow fetch FLV stream from auth protected URL.

Example

var flvPlayer = flvjs.createPlayer({
    isLive: true,
    type: 'flv',
    url: "https:/localhost/flv",
}, {
    enableWorker: false,
    deferLoadAfterSourceOpen:false,
    enableStashBuffer: false,

    // additional authorization header
    headers: {
        'Authorization': 'Basic ' + btoa(unescape(encodeURIComponent("admin:1111")))
    },
});

There is withCredentials property on dataSource but it won't work if you don't want auth popup to appear for the user on a page that contains player. That's because allowing adding 'Authorization' header manually would be beneficial.

Thank you!

@xqq
Copy link
Contributor

xqq commented Sep 20, 2018

Sorry for my late response.
It's a good idea and thanks for your contribution.

Before merging I have to update the declarations in config.js and flv.d.ts

@xqq xqq merged commit 6a0be2f into bilibili:master Sep 20, 2018
@xqq
Copy link
Contributor

xqq commented Sep 20, 2018

Now it will also work in other browsers like FireFox, etc.

Merged, thanks!

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

Successfully merging this pull request may close these issues.

2 participants