如何在angularJS中添加jPlayer函数头

tjvv9vkg  于 2022-12-10  发布在  Angular
关注(0)|答案(1)|浏览(119)

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)
 });
}
np8igboo

np8igboo1#

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.

相关问题