napster.js
napster.js copied to clipboard
Uncaught ReferenceError: DrmStreamingPlayer is not defined
I am experiencing the following error in the console. I'm following the API documentation as described in the readme. I've tried basic fixes like moving the code around in certain areas of the HTML, a script.js and in the actual napster.min.js. I've isolated the conflict to the .set method. "napster.min.js:15" refers to "Napster.member.set({.....".
napster.min.js:4 Uncaught ReferenceError: DrmStreamingPlayer is not defined
at e.auth (napster.min.js:4)
at l.<anonymous> (napster.min.js:4)
at l.a.(anonymous function) [as set] (file:///C:/Users/Ibrahim%20Iqbal/Desktop/Bootcamp%20Homework/Project-1/assets/javascript/napster.min.js:4:6296)
at napster.min.js:15
Napster.init({
consumerKey: 'ZTk2YjY4MjMtMDAzYy00MTg4LWE2MjYtZDIzNjJmMmM0YTdm',
isHTML5Compatible: true,
version: 'v2.1',
player: 'player-frame'
// player: "aside"
});
Napster.member.set({
accessToken: 'oauth access token',
refreshToken: 'oauth refresh token'
});
Napster.player.on('ready', function (e) {
Napster.member.set({ accessToken: 'oauth access token' }); // If not set earlier
Napster.player.auth();
});
Napster.player.play('tra.313617399');
Has this been deprecated by any chance?
The javascript injection they use doesn't seem to work. Here's a workaround, include this:
<script src="https://api.napster.com/v2/streaming-player.js"
type="text/javascript"/>
On Sat, Apr 13, 2019 at 11:58 AM Ibrahim A. Iqbal [email protected] wrote:
I am experiencing the following error in the console. I'm following the API documentation as described in the readme. I've tried basic fixes like moving the code around in certain areas of the HTML, a script.js and in the actual napster.min.js. I've isolated the conflict to the .set method. "napster.min.js:15" refers to "Napster.member.set({.....".
napster.min.js:4 Uncaught ReferenceError: DrmStreamingPlayer is not defined at e.auth (napster.min.js:4) at l.
(napster.min.js:4) at l.a.(anonymous function) [as set] (file:///C:/Users/Ibrahim%20Iqbal/Desktop/Bootcamp%20Homework/Project-1/assets/javascript/napster.min.js:4:6296) at napster.min.js:15 Napster.init({ consumerKey: 'ZTk2YjY4MjMtMDAzYy00MTg4LWE2MjYtZDIzNjJmMmM0YTdm', isHTML5Compatible: true, version: 'v2.1', player: 'player-frame' // player: "aside" });
Napster.member.set({ accessToken: 'oauth access token', refreshToken: 'oauth refresh token' });
Napster.player.on('ready', function (e) { Napster.member.set({ accessToken: 'oauth access token' }); // If not set earlier Napster.player.auth(); });
Napster.player.play('tra.313617399');
Has this been deprecated by any chance?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Napster/napster.js/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AApbPxTP0vDwTcQUr-34XFHjgAO2qjzlks5vgijVgaJpZM4cuNvF .
So after doing that, without actually moving the hard code around and the Napster initialization written out in the in napster.min.js file after the pre-written code, I still get the same error as above(DrmStreamingPlayer is not defined).
However, moving the initialization code into my index.html into a script tag at the end of the body will give me the following error:
index.html:1 GET https://api.napster.com/v2.2/tracks/tra.361046974 401 (Unauthorized)
Uncaught (in promise) SyntaxError: Unexpected token E in JSON at position 0 at JSON.parse (<anonymous>) at streaming-player.js:10
streaming-player.js?_=1555255466309:27 VIDEOJS: WARN: Player "napster-streaming-player" is already initialised. Options will not be applied.
You need to add your apikey. You can pass it in as a query string in the url or you can put it in the header.
To use it in query string just append to your url:
?apikey=YOURAPIKEY
On Sun, Apr 14, 2019 at 8:31 AM Ibrahim A. Iqbal [email protected] wrote:
So after doing that, without actually moving the hard code around and the Napster initialization written out in the in napster.min.js file after the pre-written code, I still get the same error as above(DrmStreamingPlayer is not defined).
However, moving the initialization code into my index.html into a script tag at the end of the body will give me the following error:
index.html:1 GET https://api.napster.com/v2.2/tracks/tra.361046974 401 (Unauthorized)
Uncaught (in promise) SyntaxError: Unexpected token E in JSON at position 0 at JSON.parse (
) at streaming-player.js:10 streaming-player.js?_=1555255466309:27 VIDEOJS: WARN: Player "napster-streaming-player" is already initialised. Options will not be applied.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/Napster/napster.js/issues/14#issuecomment-482999747, or mute the thread https://github.com/notifications/unsubscribe-auth/AApbP4X-U8k1CX2wi4zds7BMFNt8NkfBks5vg0nHgaJpZM4cuNvF .
I have the API key linked in an AJAX call in my script.js. This is the code:
`//query napster for top playlist const playlistQueryUrl = "https://api.napster.com/v2.2/tracks/top?apikey=ZTk2YjY4MjMtMDAzYy00MTg4LWE2MjYtZDIzNjJmMmM0YTdm" // const playlistQueryUrl = "https://api.napster.com/v2.0/tracks/top?apikey=ZTk2YjY4MjMtMDAzYy00MTg4LWE2MjYtZDIzNjJmMmM0YTdm"
$.ajax({ url: playlistQueryUrl, method: "GET" }).then(function(response){ trackDetails = response; console.log("this is what napster returns", response); console.log("mp3 link", response.tracks[0].previewURL); });`
The second const is commented out. I'm sorry, I'm not sure why it isn't creating a code snippet of it all.
Even without including the Napster SDK, the code you posted should work.
I have to go to church but let me take a look afterward. If you are on discord I would be happy to help walk you through it that way as well.
Ed
On Sun, Apr 14, 2019 at 9:16 AM Ibrahim A. Iqbal [email protected] wrote:
The second const is commented out. I'm sorry, I'm not sure why it isn't creating a code snippet of it all.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/Napster/napster.js/issues/14#issuecomment-483008641, or mute the thread https://github.com/notifications/unsubscribe-auth/AApbP0DUq6QExSRrtJYwy3VkLgYG1IOtks5vg1RFgaJpZM4cuNvF .
That would be fantastic. Unfortunately I have work soon but I'd like to talk through it. This is a group project I'm working on so perhaps my teammates would be able to chime in. I've provided them the code and the link to this page so you could be hearing something from them as well.
Hi Ed, I am a project teammate of Ibrahim's and can get on a discord call with you later this afternoon if you have availability. Would you be available sometime after 4PM Mountain Time?
I should be available in an hour or two from now. Let’s take this offline, you can contact me at eltmon@gmail
On Sun, Apr 14, 2019 at 10:59 AM apizarras [email protected] wrote:
Hi Ed, I am a project teammate of Ibrahim's and can get on a discord call with you later this afternoon if you have availability. Would you be available sometime after 4PM Mountain Time?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/Napster/napster.js/issues/14#issuecomment-483029912, or mute the thread https://github.com/notifications/unsubscribe-auth/AApbP8qtI37kzaT9y__9bzdFxBmEBNYVks5vg2yKgaJpZM4cuNvF .
Hi @iaiqbal! Thank you for reporting this issue! In case you did not resolve it, can you please send following info:
- which browser you are using to test
- are you using example app to test
- if you don't mind, uploading the compressed (zip) project folder, and attaching an URL here, so i can try to reproduce and debug it locally? Thanks, Tesa :)