I am developing spotify third party application using javascript API.
I am trying to play the track from certain position.
I am having following code,
player.position = 50000;
player.play(track);
But this code plays track from begining.
I want to play the track from certain position.
Is there any way to play track from certain position?
Thanks.
You need to play the track first, then as soon as playback starts seek to the location you want.
You can observe when playback starts by adding an observer for models.EVENT.CHANGE to the player object and looking at the playing property.
You can also link directly to a specific position in a track by adding #1:31 to the end of a URI, for example spotify:track:3iDK8BAaBUatPR84gdfa9g#0:15.
Related
i want to develop an google-action. (ideally using dialogflow).
but the google-action needs some features where i couldn't find a solution, and i'm not sure if it's even possible.
My Usecases:
The google action starts a mps. someone stops and exits the google action, and if the user starts the google action again, i would resume the mp3.
but i couldn't find a solution where i can determine the "offset", when the user stops the mp3.
and even i would have this offset, i didn't find a solution how to tell google assistant, that i want to play the mp3, but starts at e.g. Minute 51.
I would be really wondered, it the google action possibilitys are so extremly restricted.
can someone confirm, that this usecases are not possible, or can someone give me a hint how to do it?
i only found this one, which is restricted to start a mp3 at beginning.
https://developers.google.com/actions/assistant/responses#media_responses
Kind Regards
Stefan
To start an mp3 file at a certain point you can try the SSML tag and its clipBegin property.
clipBegin - A TimeDesignation that is the offset from the audio source's beginning to start playback from. If this value is greater than or equal to the audio source's actual duration, then no audio is inserted.
https://developers.google.com/actions/reference/ssml
To use this, your mp3 file has to be hosted using HTTPS
Hope that this helps.
You could use the conversational actions (instead of dialogflow) where media responses allow using a start_offset
....
"content": {
"media": {
"start_offset": "2.12345s",
...
For more details see
https://developers.google.com/assistant/conversational/prompts-media#MediaResponseProperties
Even conversational actions seem to be the "newest" technology for google actions. Or at least released recently.
I have a text file I created using fb2k text tools; Artist Name - Song Name \n(new line)
This file includes my full music library, including 85k songs.
I'd like to somehow convert this to a single or multiple Spotify Playlists.
playlist-converter.net is doing one song per second, which means it is going to take roughly 24 hours to create this playlist on that site.
Is there any way i can do this locally using some github script or maybe a site that allows you to upload a file which will convert fairly quickly?
Thanks in advance
I dont know if exists a ready-to-use script for this, but you can do it yourself, its not that hard if you know some programming language.
You can use Spotify API
https://developer.spotify.com/
For each line, you will have to call API with the name of song and Artist
https://developer.spotify.com/web-api/search-item/
So will return an JSON object, with the id of song.
For each id you will have to call api again, to include the new song
https://developer.spotify.com/web-api/add-tracks-to-playlist/
Thats it, good luck !
I am looking to create a custom spotify playlist rather than use the generator via the website. I need a way of grabbing this xml, rather like the lookup and search facilities that the webAPI provide. I have tried to use a playlist spotifyURI with the lookup functionality but it doesnt seem to work.
e.g.
http://ws.spotify.com/lookup/1/?uri=spotify:user:XXX:playlist:YYY
However, using this just gives me the following error :
"You hit the rate limit, wait 10 seconds and try again"
I don't think I have really hit the hitrate, I only tried it a few times.
If this isnt the way to go, what other options are there ? libSpotify ? This seems like rather a bigger solution for just getting some xml for a playlist.
Any help appreciated.
The web API doesn't support playlist lookup at all. If you want to find playlist data, you'd have to use libspotify.
I just started writing a little Spotify App and can't figure out how to invoke the two functions next/star from Javascript. I just need this simple functionality: From within my App (Javascript) call a method that skips the current track and plays the next one (if there is any) OR call a method that "stars" (is this really a verb?) the current song.
Is this API DOC the only resource for building my own App? Thanks in advance for any hints on this!
UPDATE: Just found out how to SKIP: sp.trackPlayer.skipToNextTrack();
Unfortunately, how to "star" a track remains unknown.
UPDATE 2: GOT IT! : models.library.starredPlaylist.add(models.player.track); – yep that makes sense.
The correct way to star a track is indeed the function you wrote:
models.library.starredPlaylist.add(models.player.track);
trackPlayer is not a supported object that shouldn't be accessed by developers since it's not versioned properly. This means that it may break in the future when we do updates to the platform bridge.
We recommend only using the documented classes on our developer website.
https://developer.spotify.com/technologies/apps/docs/beta/
The correct way to skip to the next track is to use:
models.player.next()
Is there any way to disable the next/previous button in the Spotify apps api, like SoundDrop was able to do?
Thanks
When you play a track without a context, or play a track with a context containing only one track, the playback controls are disabled.
SoundDrop takes the first approach — it only plays a single track at a time with no context, and manually plays the next track when it's time.
I managed to resolve this issue.
Setting the context to a context with only one track wasn't the entire solution, since I had to run an undocumented function on the playlist too.
But take a look at my solution here:
Disable next previous buttons in spotify