简体   繁体   中英

how to add header in jPlayer function in angularJS

I tried like by adding headers inside jPlayer, its not working

const httpHeader = { 'authorization' : '123445'};
if (audioUrl) {
 $(this).jPlayer('setMedia', {
  mp3: audioUrl,
  duration: parseInt(duration, 10),
  headers : new Headers(httpHeader)
 });
}

Seems like the setMedia method does not have a headers property, so this code will not work as-is.

To set the headers for a jPlayer instance, you'll need to use the jPlayer method to set the headers for the player as a whole, rather than setting them for a specific media file. To do this, you can use the option method to set the headers property for the player, like this:

const httpHeader = { 'authorization' : '123445'};
$(this).jPlayer('option', 'headers', new Headers(httpHeader));

This will set the headers for the player instance, and they will be used for all media files that are loaded by the players.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM