Editing Time Field in a Spotify App Playlist - spotify

I am having trouble removing the time field from a playlist in the Spotify App. I only want to display Song title, Artist and Album. Any help on this topic would be truly helpful.

You can specify which track attributes to display using the List object. An example is here: http://deceptacle.com/2011/12/26/spotify-app-api-some-things/
var list = new views.List(playlist, function (track) {
return new views.Track(track, views.Track.FIELD.NAME |
views.Track.FIELD.ARTIST |
views.Track.FIELD.ALBUM);
});
$("#playlist").append(list.node);
Update
More fleshed out example:
var pl = m.Playlist.fromURI("spotify:user:rhino_records:playlist:6sSFeKDgDxVR81YqNOuPf2");
var list = new v.List(pl, function (track) {
return new views.Track(track, views.Track.FIELD.NAME |
views.Track.FIELD.ARTIST |
views.Track.FIELD.ALBUM);
});
document.body.appendChild(list.node);
m is the models namespace, v is the views namespace. For some reason, it's not quite working for me. It seems like the observer methods aren't being called at the moment. Seems to be a spotify backend thing though. It seems to get called eventually after some prodding

Related

How do I query the vimeo api for a specific video title?

Hi I'm querying for a specific video by title - and at the moment I get mixed results.
my videos are all named with a consecutive number at the end ie ANDNOW2022_00112, ANDNOW2022_00113 etc
When I search /videos/?fields=uri,name&query=ANDNOW2022_00112 I get all of the videos returned
I've also tried the query_fields using
/me/videos?query_fields=title&sort=alphabetical&query=ANDNOW2022_00112
I just want the one I've searched for - or a no results returned.
At the moment I get all of the videos with AN2022 in the title/name. Now 'usually' the one I searched for is at the top of the list but not everytime.
Any tips appreciated.
Okay I'm not going mad :)
This is from Vimeo and is here for those with the same issue - basically to get t to work you need to understand that:
After speaking with our engineers, the current search capability are not "Exact" search.
When adding numbers or underscores the search is split into parts so "ANDNOW2022_00112" is transforming the query into the parts "andnow2022", "andnow", "2022", and "00112". So this is why your seeing these results. Our engineering team are in the process of improving the search capabilities and hope to provide a release in the near future.
Which means for now I'll have to rename my files.
Preface:
Vimeo does not currently offer an API endpoint for exact title search — but even if it did — it's possible to upload multiple videos and assign them identical titles. There's no way to use the API to positively identify a video by title — this is why every uploaded video is assigned a unique ID.
Solution:
Because the API returns data which includes an array of video objects, you can solve this problem in the same way you'd solve any similar problem in JavaScript where you have to find an element in an array: Array.prototype.find()
Here's how you can apply it to your problem:
Query the API using the parameters you described in your question.
You might also be interested in using the sort and direction parameters for greater control over a deterministic sort order.
Find the first item in the returned array of video objects that match your expected text exactly, and return it (or undefined if it doesn't exist)
Here's a code example with some static data from the API that was used to search for the video Mercedes Benz from the user egarage — note that I've omitted quite a few (irrelevant) fields from the response in order to keep the example small:
// Mocking fetch for this example:
function fetch (_requestInfo, _init) {
const staticJson = `{"total":2,"page":1,"per_page":25,"paging":{"next":null,"previous":null,"first":"/users/egarage/videos?query_fields=title&query=Mercedes%20Benz&sort=alphabetical&direction=asc&page=1","last":"/users/egarage/videos?query_fields=title&query=Mercedes%20Benz&sort=alphabetical&direction=asc&page=1"},"data":[{"uri":"/videos/61310450","name":"50th Anniversary of the Pagoda SL -- Mercedes-Benz Classic Vehicles","description":"Penned by designer Paul Bracq, the W113 SL had big shoes to fill: it had the incredible task of succeeding the original and instantly iconic 300 SL Gullwing. But you can't copy a legend, so Bracq designed one of his own. Straight lines replaced curves and a low-slung roof was replaced by a high top design that gave the car its nickname: the Pagoda.\\n\\nMUSIC: Developer Over Time","type":"video","link":"https://vimeo.com/61310450"},{"uri":"/videos/55837293","name":"Mercedes Benz","description":"To celebrate Mercedes Benz 125th birthday, the 2011 Pebble Beach Concours d’Elegance showcased the models that trace the lineage to Benz and Daimler —particularly Mercedes-Benz. This tribute chronicled early racing greats, coachbuilt classics, and preservation cars. Produced in association with DriveCulture.","type":"video","link":"https://vimeo.com/55837293"}]}`;
return Promise.resolve(new Response(staticJson));
}
async function fetchVideoByTitle (token, userId, videoTitle) {
const url = new URL(`https://api.vimeo.com/users/${userId}/videos`);
url.searchParams.set("query_fields", "title");
url.searchParams.set("query", videoTitle);
url.searchParams.set("sort", "alphabetical");
url.searchParams.set("direction", "asc");
const headers = new Headers([
["Authorization", `Bearer ${token}`],
]);
const response = await fetch(url.href, {headers});
const parsedJson = await response.json();
// Find the video that matches (if it exists):
const maybeFirstVideoObj = parsedJson.data.find(video => video.name === videoTitle);
return maybeFirstVideoObj;
}
async function main () {
const video = await fetchVideoByTitle(
"YOU_ACTUAL_TOKEN",
"egarage",
"Mercedes Benz",
);
console.log(video); // {name: "Mercedes Benz", link: "https://vimeo.com/55837293", ...}
}
main();

Get list of playlists in Xamarin.iOS

I am having difficulty in obtaining a collection of playlists for the iPhone with Xamarin.iOS. I want to populate a list of my custom objects with the playlist descriptions. I found a page in Apple documentation on how to do it in Obj-C. However, whatever I do in Xamarin I either get invalid cast exceptions or some other error.
Getting the playlists into a collection is OK. However, it is getting the name of the playlist after that where the problem lies.
private List<Playlist> GetPlaylists()
{
MPMediaQuery mq = MPMediaQuery.playlistsQuery;
// At this point mq.Collections has a reference to the playlists. However I have no way of getting the Name/Description of the playlist.
// Thats why I was attempting to use MPMediaPlaylist
// MPMediaPlaylist[] mp1 = mq.Collections as MPMediaPlaylist[]; - doesn't work - results in mp1 being null
List<Playlist> playlists = (from p in mq.Collections
select new Playlist () { PlaylistDescription = ((MPMediaPlaylist)p).ValueForProperty("MPMediaPlaylistPropertyName").ToString()}
).ToList();
return playlists;
}
Another variation I had was as follows (but again received an invalid cast exception in the iteration of the forearch i.e. MediaPlaylist in mp1):
MPMediaQuery mq = MPMediaQuery.playlistsQuery;
Array mp1 = mq.Collections as Array;
List<Playlist> playlists = new List<Playlist> ();
foreach (MPMediaPlaylist playlist in mp1) {
playlists.Add (new Playlist () { PlaylistDescription = playlist.ValueForProperty ("MPMediaPlaylistPropertyName").ToString() });
}
As I have commented i the code, I can get a handle on the playlists through the collections property on the query. However, I cannot get the Name/Title/Description of the playlist. That is why I was attempting to use the MPMediaPlaylist casting.
In the immediate window and watch window I tried to cast (MPMediaPlaylist)mq.collections[0] but again got an invalid cast exception.
I came across the following documentation in apple documentation for Obj-C but I have been unsuccessful in reproducing it as you can see above. I'd be very grateful if someone could cast an eye over what I have above and also this Objective-C link and advise.
Many thanks,
Tomás
I am just going to put this here.... if someone runs in to this problem in the future!
So to get list of playlists you should do the following:
MPMediaQuery playlistQuery = MPMediaQuery.PlaylistsQuery;
MPMediaItemCollection[] playlistCollection = playlistQuery.Collections;
foreach(MPMediaItemCollection collection in playlistCollection){
NSString key = MPMediaPlaylistProperty.Name;
string name = collection.ValueForKey(key).ToString();
//Do whatever you need with the info
}

Spotify API: Create Radio Button from Temporary Playlist Not supported?

I'm building an app that is generating a temporary playlist of tracks. I am then attempting to create a "Start Radio" button for that temporary playlist.
The button is generated, but when I click it, the screen changes to radio, but doesn't play nor does it load any radio station.
My guess is that this is not supported, because if I create a regular playlist and do it, it does play the radio...
But I cannot find any information in the API that confirms or deny my guess.
Does any one know for certain if this is not supported?
I would really rather do this from a temp playlist than have to maintain a real one...
You are right. The Start Radio Button doesn't support temporary playlists. And, unfortunately, the documentation doesn't mention this.
It seems that the track data attached to the temporary playlist can't be passed to the Radio app, so the Radio app loads with no context information.
The only way to achieve this is, as you said, creating a persistent playlist and create a radio button for that. In order to not create a new playlist every time, you can also try to find the playlist you created previously in the user's library.
See this code snippet:
require(['$api/models', '$api/library#Library', '$views/buttons#StartRadioButton'],
function(models, Library, StartRadioButton) {
// create a temporary playlist with some tracks
var playlistName = 'Some name';
models.Playlist.create(playlistName).done(function(playlist) {
playlist.load('tracks').done(function(loadedPlaylist) {
var track1 = models.Track.fromURI('spotify:track:5EB60KIbYgL8nWrHoYbfv4');
var track2 = models.Track.fromURI('spotify:track:7GPuYTiBA5BloBnFaQBjbw');
loadedPlaylist.tracks.add(track1);
loadedPlaylist.tracks.add(track2);
// now we can add a button to start a radio base on the newly
// created playlist
var button = StartRadioButton.forPlaylist(loadedPlaylist);
document.body.appendChild(button.node);
// bonus: we can also search for the playlist in the user's library
// so we don't have to create a new one all the time.
// this will work as long as we can find the playlist we created by name
// (i.e. it hasn't been renamed).
var currentLibrary = Library.forCurrentUser();
console.log(currentLibrary);
currentLibrary.playlists.snapshot().done(function(p) {
for (var i = 0; i < p.length; i++) {
var playlistFromLibrary = p.get(i);
if (playlistFromLibrary && playlistFromLibrary.name == playlistName) {
var button = StartRadioButton.forPlaylist(playlistFromLibrary);
document.body.appendChild(button.node);
}
}
});
});
});
});

How do I create links to an artist, track or album in a Spotify App as described in the App Guidelines?

Point 16. of the app design guidelines describes how links to artists, tracks or albums should look like but I can't find a place that tells how one can create such a link with HTML/CSS and/or Javascript.
Horse Of a Different Color
The client will be smart enough to do the right thing. You can get these URIs from Track, Artist, Album and Playlist objects in the API.
The solution is so simple... It's the player view we're talking about here. See this example:
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var views = sp.require("sp://import/scripts/api/views");
$(document).ready(function()
{
new models.Album.fromURI("spotify:album:7auFBtmCGcTn7ElPelMLPn", function(ctx)
{
var player = new views.Player();
player.context = ctx;
$("#my-album-player").append(player.node);
});
});
Thanks to ikenndac who sent me on the right track!

Hide Now Playling Track Informations

is it possible, from an spotify application, to hide or overwrite the "now playing" pannel (the cover and artist name/track name of the playing track) ?
Thx, for your help.
I try to modify the Album object or the Track object provided to the player but it don't work :
models.Album.fromURI("spotify:album:3ty039P7JO7bTcWtWi1AP6", function(a) {
var player = new v.Player();
var track = a.get(0);
//a.artist = "TOTO";
//a.cover = "sp://import/img/placeholders/300-album.png";
//track.image = 'sp://import/img/placeholders/300-album.png';
track.name = "Test";
player.play(track,a);
});
This is not possible in the current API, mainly because we don't want people overwriting now playing information with adverts and stuff.

Resources