Class: Spotify::API Private
- Inherits:
-
Object
- Object
- Spotify::API
- Extended by:
- FFI::Library, APIHelpers
- Includes:
- APIHelpers
- Defined in:
- lib/spotify/api.rb,
lib/spotify/types.rb,
lib/spotify/api/link.rb,
lib/spotify/api/user.rb,
lib/spotify/api/album.rb,
lib/spotify/api/error.rb,
lib/spotify/api/image.rb,
lib/spotify/api/inbox.rb,
lib/spotify/api/track.rb,
lib/spotify/api/artist.rb,
lib/spotify/api/search.rb,
lib/spotify/api/session.rb,
lib/spotify/api/playlist.rb,
lib/spotify/api/album_browse.rb,
lib/spotify/api/artist_browse.rb,
lib/spotify/api/miscellaneous.rb,
lib/spotify/api/toplist_browse.rb,
lib/spotify/api/playlist_container.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The API is private because this class is an implementation detail.
You should never call any Spotify::API.method() directly, but instead you should call them via Spotify.method(). libspotify is not thread-safe, but it is documented to be okay to call the API from multiple threads if you only call one function at a time, which is ensured by the lock in the Spotify module.
API is the class which has all libspotify functions attached.
All functions are attached as both instance methods and class methods, mainly because that’s how FFI works it’s magic with attach_function. However, as this is a class it allows to be instantiated.
Link collapse
-
#link_as_album(link) ⇒ Album?
Album pointed to by the link, or nil if not an album.
-
#link_as_artist(link) ⇒ Artist?
Artist pointed to by the link, or nil if not an artist.
-
#link_as_string(link) ⇒ String
Retrieve string representation of link.
-
#link_as_track(link) ⇒ Track?
Track pointed to by the link, or nil if not a track.
-
#link_as_track_and_offset(link) ⇒ Array<Track, Integer>?
Track and offset (in ms) as a tuple, or nil.
-
#link_as_user(link) ⇒ User?
User pointed to by the link, or nil if not a user.
- #link_create_from_album(album) ⇒ Link?
- #link_create_from_album_cover(album, image_size) ⇒ Link?
- #link_create_from_artist(artist) ⇒ Link?
- #link_create_from_artist_portrait(artist, image_size) ⇒ Link?
- #link_create_from_artistbrowse_portrait(artist_browse, index) ⇒ Link?
- #link_create_from_image(image) ⇒ Link
- #link_create_from_playlist(playlist) ⇒ Link?
- #link_create_from_search(search) ⇒ Link?
-
#link_create_from_string(spotify_uri) ⇒ Link
Create a Link from a Spotify URI or Spotify HTTP URL.
- #link_create_from_track(track, offset) ⇒ Link?
- #link_create_from_user(user) ⇒ Link
-
#link_type(link) ⇒ Symbol
Type of link, one of :invalid, :track, :album, :artist, :search, :playlist, :profile, :starred, :localtrack, :image.
User collapse
-
#user_canonical_name(user) ⇒ String
Canonical username of user, the one used by Spotify in just about all places.
-
#user_display_name(user) ⇒ String
Display name of user.
-
#user_is_loaded(user) ⇒ Boolean
True if user has finished loading.
Album collapse
-
#album_artist(album) ⇒ Artist?
Authoring artist of the album.
-
#album_cover(album, image_size) ⇒ String?
Image ID to pass to #image_create, or nil if the album has no image.
-
#album_is_available(album) ⇒ Boolean
True if the album is available for playback.
-
#album_is_loaded(album) ⇒ Boolean
True if the album is populated with data.
-
#album_name(album) ⇒ String
Name of the album.
-
#album_type(album) ⇒ Symbol
Album type, one of :album, :single, :compilation, :unknown.
-
#album_year(album) ⇒ String
Release year of the album.
Error collapse
-
#error_message(error) ⇒ String
Explanatory error message for an error code.
Image collapse
-
#image_add_load_callback(image, callback, userdata) ⇒ Symbol
Add a callback that will be invoked when the image is loaded.
-
#image_create(session, image_id) ⇒ Image
Image from an image id.
-
#image_create_from_link(session, link) ⇒ Image?
Image pointed to by link, or nil if link is not a valid image link.
-
#image_data(image) ⇒ String?
Retrieves raw image data.
-
#image_error(image) ⇒ Symbol
Image error code.
-
#image_format(image) ⇒ Symbol
Image format, one of :unknown, or :jpeg.
-
#image_image_id(image) ⇒ String
Image id.
-
#image_is_loaded(image) ⇒ Boolean
True if the image information has been retrieved.
-
#image_remove_load_callback(image, callback, userdata) ⇒ Symbol
Remove an image load callback previously added with #image_add_load_callback.
Inbox collapse
-
#inbox_error(inbox) ⇒ Symbol
Error status of inbox post.
-
#inbox_post_tracks(session, username, tracks, message, callback, userdata) ⇒ Inbox
Post an array of tracks to a Spotify user’s inbox.
Track collapse
-
#localtrack_create(artist, title, album, duration) ⇒ Track
Create a local Track reference, whatever that means.
-
#track_album(track) ⇒ Album?
Album of the track.
-
#track_artist(track, index) ⇒ Artist?
Artist at index.
-
#track_disc(track) ⇒ Integer
Disc number for the track, 1..(total number of discs on album).
-
#track_duration(track) ⇒ Integer
Duration of the track in milliseconds.
-
#track_error(track) ⇒ Symbol
Error code.
-
#track_get_availability(session, track) ⇒ Symbol
Track availability, one of :unavailable, :available, :not_streamable, :banned_by_artist.
-
#track_get_playable(session, track) ⇒ Track
The actual track that will be played if track is scheduled for playback.
-
#track_index(track) ⇒ Integer
Position of track on it’s disc, starts at 1.
-
#track_is_autolinked(session, track) ⇒ Boolean
True if the track is automatically linked to another playable version of the track.
-
#track_is_loaded(track) ⇒ Boolean
True if track has finished loading.
-
#track_is_local(session, track) ⇒ Boolean
True if the track is a local track.
-
#track_is_placeholder(track) ⇒ Boolean
Placeholder tracks are a way to store non-track items in a playlist.
-
#track_is_starred(session, track) ⇒ Boolean
True if the track is starred by the current user.
-
#track_name(track) ⇒ String
Track name.
-
#track_num_artists(track) ⇒ Integer
Number of artists performing the track.
-
#track_offline_get_status(track) ⇒ Symbol
Offline status of track, one of :no, :waiting, :downloading, :done, :error, :done_expired, :limit_exceeded, :done_resync.
-
#track_popularity(track) ⇒ Integer
Popularity of the track, 0..100.
-
#track_set_starred(session, tracks, starred) ⇒ Symbol
Star or unstar a list of tracks.
Artist collapse
-
#artist_is_loaded(artist) ⇒ Boolean
True if the artist is populated with data.
-
#artist_name(artist) ⇒ String
Name of the artist.
-
#artist_portrait(artist, image_size) ⇒ String?
Image ID to pass to #image_create, or nil if the artist has no image.
Search collapse
-
#search_album(search, index) ⇒ Album?
Album at index.
-
#search_artist(search, index) ⇒ Artist?
Artist at index.
-
#search_create(session, query, track_offset, track_count, album_offset, album_count, artist_offset, artist_count, playlist_offset, playlist_count, search_type, callback, userdata) ⇒ Search
Fire off a search query for tracks, albums, artists, and playlists.
-
#search_did_you_mean(search) ⇒ String
Spotify’s guess at what the query might have meant instead.
-
#search_error(search) ⇒ Symbol
Error code.
-
#search_is_loaded(search) ⇒ Boolean
True if the search has completed.
-
#search_num_albums(search) ⇒ Integer
Number of albums in the search result.
-
#search_num_artists(search) ⇒ Integer
Number of artists in the search result.
-
#search_num_playlists(search) ⇒ Integer
Number of playlists in the search result.
-
#search_num_tracks(search) ⇒ Integer
Number of tracks in the search result.
-
#search_playlist(search, index) ⇒ Playlist?
Playlist at index.
-
#search_playlist_image_uri(search, index) ⇒ String?
Image uri for playlist at index.
-
#search_playlist_name(search, index) ⇒ String?
Name for playlist at index.
-
#search_playlist_uri(search, index) ⇒ String?
Spotify uri for playlist at index.
-
#search_query(search) ⇒ String
Search query.
-
#search_total_albums(search) ⇒ Integer
Number of total albums in the search result.
-
#search_total_artists(search) ⇒ Integer
Number of total artists in the search result.
-
#search_total_playlists(search) ⇒ Integer
Number of total playlists in the search result.
-
#search_total_tracks(search) ⇒ Integer
Number of total tracks in the search result.
-
#search_track(search, index) ⇒ Track?
Track at index.
Session collapse
-
#offline_num_playlists(session) ⇒ Integer
Total number of playlists marked for offline synchronization.
-
#offline_sync_get_status(session, offline_sync_status) ⇒ Boolean
True if offline synching is enabled.
-
#offline_time_left(session) ⇒ Integer
Remaining time (in seconds) until offline key store expires and user is required to relogin.
-
#offline_tracks_to_sync(session) ⇒ Integer
Total number of tracks left to sync before all offline content has downloaded.
-
#session_connectionstate(session) ⇒ Symbol
Current session connection state, one of :logged_out, :logged_in, :disconnected, :undefined, :offline.
-
#session_create(config) ⇒ Array<Symbol, Session>
A tuple of error code, and session.
-
#session_flush_caches(session) ⇒ Symbol
Force libspotify to write all disk-stored data to disk immediately.
-
#session_forget_me(session) ⇒ Symbol
Forget a previously remembered user.
-
#session_get_volume_normalization(session) ⇒ Boolean
Current volume normalization setting.
-
#session_inbox_create(session) ⇒ Playlist
Inbox playlist for currently logged in user (playlist where items sent by other users are posted to).
-
#session_is_private_session(session) ⇒ Boolean
True if private session is enabled.
-
#session_is_scrobbling(session, social_provider) ⇒ Symbol
Retrieve the scrobbling state.
-
#session_is_scrobbling_possible(session, social_provider) ⇒ Boolean
Retrieve if it is possible to scrobble to the social provider.
-
#session_login(session, username, password, remember_me, password_blob) ⇒ Symbol
Schedule a login.
-
#session_logout(session) ⇒ Symbol
Schedule a logout.
-
#session_player_load(session, track) ⇒ Symbol
Load the specified track for playback.
-
#session_player_play(session, play) ⇒ Symbol
Play or pause the currently loaded track.
-
#session_player_prefetch(session, track) ⇒ Symbol
Tell libspotify to start preloading a track so that #session_player_load has less work to do.
-
#session_player_seek(session, position) ⇒ Symbol
Seek to position in the currently loaded track.
-
#session_player_unload(session) ⇒ Symbol
Stop playback and clear the currently loaded track.
-
#session_playlistcontainer(session) ⇒ PlaylistContainer?
Playlist container for currently logged in user.
-
#session_preferred_bitrate(session, bitrate) ⇒ Symbol
Set preferred bitrate for music streaming.
-
#session_preferred_offline_bitrate(session, bitrate, resync) ⇒ Symbol
Set preferred bitrate for offline playback.
-
#session_process_events(session) ⇒ Integer
Tell libspotify to process pending events from the backend.
-
#session_publishedcontainer_for_user_create(session, username) ⇒ PlaylistContainer?
Published playlists container for the specified user.
-
#session_relogin(session) ⇒ Symbol
Log in a previously remembered login from #session_login.
-
#session_remembered_user(session) ⇒ String?
Retrieve the remembered user from #session_login.
-
#session_set_cache_size(session, cache_size) ⇒ Symbol
Set the allowed disk cache size used by libspotify.
-
#session_set_connection_rules(session, rules) ⇒ Symbol
Set rules for how libspotify connects to Spotify servers and synchronizes offline content.
-
#session_set_connection_type(session, type) ⇒ Symbol
Set current connection type.
-
#session_set_private_session(session, enabled) ⇒ Symbol
Set if private session is enabled.
-
#session_set_scrobbling(session, social_provider, scrobbling_state) ⇒ Symbol
Set if scrobbling should be enabled.
-
#session_set_social_credentials(session, social_provider, username, password) ⇒ Symbol
Set the user’s credentials for a social provider.
-
#session_set_volume_normalization(session, normalize) ⇒ Symbol
Set volume normalization.
-
#session_starred_create(session) ⇒ Playlist?
Starred playlist for currently logged in user.
-
#session_starred_for_user_create(session, username) ⇒ Playlist?
Starred playlist for the specified user.
-
#session_user(session) ⇒ User?
Currently logged in user.
-
#session_user_country(session) ⇒ String
Currently logged in user’s country code.
-
#session_user_name(session) ⇒ String
Canonical name for currently logged in user.
-
#session_userdata(session) ⇒ FFI::Pointer
Userdata from config in #session_create.
Playlist collapse
-
#playlist_add_callbacks(playlist, playlist_callbacks, userdata) ⇒ Symbol
Attach callbacks to the playlist, used for getting change notifications.
-
#playlist_add_tracks(playlist, tracks, offset, session) ⇒ Symbol
Add tracks to the playlist.
-
#playlist_create(session, link) ⇒ Playlist?
Instantiate a Playlist from a Link.
-
#playlist_get_description(playlist) ⇒ String?
Playlist description, if available.
-
#playlist_get_image(playlist) ⇒ String?
Retrieve playlist image ID as a string.
-
#playlist_get_offline_download_completed(session, playlist) ⇒ Integer
Percentage of playlist downloaded, 0..100.
-
#playlist_get_offline_status(session, playlist) ⇒ Symbol
Playlist offline status, one of :no, :yes, :downloading, or :waiting.
-
#playlist_has_pending_changes(playlist) ⇒ Boolean
True if the playlist has local changes that have not yet been acknowledged by Spotify backend.
-
#playlist_is_collaborative(playlist) ⇒ Boolean
True if the playlist is collaborative, i.e.
-
#playlist_is_in_ram(session, playlist) ⇒ Boolean
True if playlist is loaded in memory, as opposed to only stored on disk.
-
#playlist_is_loaded(playlist) ⇒ Boolean
True if playlist is loaded.
-
#playlist_name(playlist) ⇒ String
Name of the playlist.
-
#playlist_num_subscribers(playlist) ⇒ Integer
Number of playlist subscribers.
-
#playlist_num_tracks(playlist) ⇒ Integer
Number of tracks in the playlist.
-
#playlist_owner(playlist) ⇒ User
Owner of the playlist.
-
#playlist_remove_callbacks(playlist, playlist_callbacks, userdata) ⇒ Symbol
Remove playlist callbacks previously added with #playlist_add_callbacks.
-
#playlist_remove_tracks(playlist, indices) ⇒ Symbol
Remove tracks from the playlist at the given indices.
-
#playlist_rename(playlist, new_name) ⇒ Symbol
Rename the playlist.
-
#playlist_reorder_tracks(playlist, indices, index) ⇒ Symbol
Move tracks at the given indices to position index and forward.
-
#playlist_set_autolink_tracks(playlist, autolink) ⇒ Symbol
Set autolinking state for a playlist.
-
#playlist_set_collaborative(playlist, collaborative) ⇒ Symbol
Set collaborative status on a playlist.
-
#playlist_set_in_ram(session, playlist, in_ram) ⇒ Symbol
Set if playlist should be loaded into memory, as opposed to only read from on disk.
-
#playlist_set_offline_mode(session, playlist, offline) ⇒ Symbol
Set if playlist should be marked for offline playback.
- #playlist_subscribers(playlist) ⇒ Subscribers
-
#playlist_track(playlist, index) ⇒ Track?
Track at index.
-
#playlist_track_create_time(playlist, index) ⇒ Integer
Time in seconds since unix epoch that track was added at index in the playlist.
-
#playlist_track_creator(playlist, index) ⇒ User?
User that added the track at index in the playlist.
-
#playlist_track_message(playlist, index) ⇒ String
Message attached to a playlist item.
-
#playlist_track_seen(playlist, index) ⇒ Boolean
True if playlist has been marked as seen with #playlist_track_set_seen.
-
#playlist_track_set_seen(playlist, index, seen) ⇒ Symbol
Set
seenflag on track. -
#playlist_update_subscribers(session, playlist) ⇒ Symbol
Request download of the subscribers list.
AlbumBrowse collapse
-
#albumbrowse_album(album_browse) ⇒ Album?
The album being browsed.
-
#albumbrowse_artist(album_browse) ⇒ Artist?
The authoring artist of the album being browsed.
-
#albumbrowse_backend_request_duration(album_browse) ⇒ Integer
The time (in ms) that was spent waiting for the Spotify backend to serve the request, -1 if served from local cache.
-
#albumbrowse_copyright(album_browse, index) ⇒ String?
The copyright string at index.
-
#albumbrowse_create(session, album, albumbrowse_complete_callback, userdata) ⇒ AlbumBrowse
A request for browsing an album.
-
#albumbrowse_error(album_browse) ⇒ Symbol
Album browsing error code.
-
#albumbrowse_is_loaded(album_browse) ⇒ Boolean
True if the album browse request has completed.
-
#albumbrowse_num_copyrights(album_browse) ⇒ Integer
Number of copyright strings on the album being browsed.
-
#albumbrowse_num_tracks(album_browse) ⇒ Integer
Number of tracks on the album being browsed.
-
#albumbrowse_review(album_browse) ⇒ String
The review for the album being browsed.
-
#albumbrowse_track(album_browse, index) ⇒ Track?
The track at index.
ArtistBrowse collapse
-
#artistbrowse_album(artist_browse, index) ⇒ Track?
The album at index.
-
#artistbrowse_artist(artist_browse) ⇒ Artist?
The artist being browsed.
-
#artistbrowse_backend_request_duration(artist_browse) ⇒ Integer
The time (in ms) that was spent waiting for the Spotify backend to serve the request, -1 if served from local cache.
-
#artistbrowse_biography(artist_browse) ⇒ String
The review for the artist being browsed.
-
#artistbrowse_create(session, artist, type, callback, userdata) ⇒ ArtistBrowse
A request for browsing an artist.
-
#artistbrowse_error(artist_browse) ⇒ Symbol
Artist browsing error code.
-
#artistbrowse_is_loaded(artist_browse) ⇒ Boolean
True if the artist browse request has completed.
-
#artistbrowse_num_albums(artist_browse) ⇒ Integer
Number of artist albums.
-
#artistbrowse_num_portraits(artist_browse) ⇒ Integer
Number of artist portraits.
-
#artistbrowse_num_similar_artists(artist_browse) ⇒ Integer
Number of similar artists.
-
#artistbrowse_num_tophit_tracks(artist_browse) ⇒ Integer
Number of tophit tracks.
-
#artistbrowse_num_tracks(artist_browse) ⇒ Integer
Number of artist tracks.
-
#artistbrowse_portrait(artist_browse, index) ⇒ String?
Image ID to pass to #image_create.
-
#artistbrowse_similar_artist(artist_browse, index) ⇒ Track?
A similar artist at index.
-
#artistbrowse_tophit_track(artist_browse, index) ⇒ Track?
The tophit track at index.
-
#artistbrowse_track(artist_browse, index) ⇒ Track?
The track at index.
Miscellaneous collapse
-
#build_id ⇒ String
Libspotify build ID.
ToplistBrowse collapse
-
#toplistbrowse_album(toplist_browse, index) ⇒ Album?
Album at index.
-
#toplistbrowse_artist(toplist_browse, : int) ⇒ Artist?
Artist at index.
-
#toplistbrowse_backend_request_duration(toplist_browse) ⇒ Integer
The time in ms that was spent waiting for Spotify backend to serve request, or -1 if served from cache.
-
#toplistbrowse_create(session, type, region, username, callback, userdata) ⇒ Object
Initiate a request for browsing a toplist.
-
#toplistbrowse_error(toplist_browse) ⇒ Symbol
Error code.
-
#toplistbrowse_is_loaded(toplist_browse) ⇒ Boolean
True if toplist request has finished loading.
-
#toplistbrowse_num_albums(toplist_browse) ⇒ Integer
Number of albums in the toplist result.
-
#toplistbrowse_num_artists(toplist_browse) ⇒ Integer
Number of artists in the toplist result.
-
#toplistbrowse_num_tracks(toplist_browse) ⇒ Integer
Number of tracks in the toplist result.
-
#toplistbrowse_track(toplist_browse, index) ⇒ Track?
Track at index.
PlaylistContainer collapse
-
#playlistcontainer_add_callbacks(container, container_callbacks, userdata) ⇒ Symbol
Attach callbacks to the container, used for getting change notifications.
-
#playlistcontainer_add_folder(container, index, folder_name) ⇒ Object
Create a new folder in the container.
-
#playlistcontainer_add_new_playlist(container, playlist_name) ⇒ Playlist?
Add a new playlist to the end of the container.
-
#playlistcontainer_add_playlist(container, link) ⇒ Playlist?
Add an existing playlist to the end of the container.
-
#playlistcontainer_clear_unseen_tracks(container, playlist) ⇒ Integer
Clear unseen tracks for a playlist on a container.
-
#playlistcontainer_get_unseen_tracks(container, playlist) ⇒ Array<Track>
Number of new tracks in playlist since #playlistcontainer_clear_unseen_tracks was called.
-
#playlistcontainer_is_loaded(container) ⇒ Boolean
True if the container is loaded.
-
#playlistcontainer_move_playlist(container, index, new_position, dry_run) ⇒ Symbol
Move a playlist to another position in the container.
-
#playlistcontainer_num_playlists(container) ⇒ Integer
Number of playlists in container.
-
#playlistcontainer_owner(container) ⇒ User
Owner of the container.
-
#playlistcontainer_playlist(container) ⇒ Playlist?
Playlist at index.
-
#playlistcontainer_playlist_folder_id(container, index) ⇒ Integer
Folder id at index.
-
#playlistcontainer_playlist_folder_name(container, index) ⇒ String?
Retrieve folder name of a folder in a container.
-
#playlistcontainer_playlist_type(container, index) ⇒ Symbol
Playlist type of playlist at index, one of :playlist, :start_folder, :end_folder, :placeholder.
-
#playlistcontainer_remove_callbacks(container, container_callbacks, userdata) ⇒ Symbol
Remove container callbacks previously added with #playlistcontainer_add_callbacks.
-
#playlistcontainer_remove_playlist(container, index) ⇒ Symbol
Remove a playlist from a container.
Class Method Summary collapse
-
.attach_function(c_name = nil, name, args, returns, &block) ⇒ Object
private
Overloaded to ensure all methods are defined as blocking, and they return a managed pointer with the correct refcount.
Methods included from APIHelpers
with_buffer, with_string_buffer
Class Method Details
.attach_function(c_name = nil, name, args, returns, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Overloaded to ensure all methods are defined as blocking, and they return a managed pointer with the correct refcount.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/spotify/api.rb', line 40 def self.attach_function(c_name = nil, name, args, returns, &block) if returns.respond_to?(:retaining_class) && name !~ /create/ returns = returns.retaining_class end = { blocking: true } name = name.to_sym c_name ||= :"sp_#{name}" super(name, c_name, args, returns, ) if block_given? alias_method c_name, name define_method name, &block singleton_class.instance_eval do alias_method c_name, name define_method name, &block end name end end |
Instance Method Details
#album_artist(album) ⇒ Artist?
the album must be loaded, or this function always return nil.
Returns authoring artist of the album.
22 |
# File 'lib/spotify/api/album.rb', line 22 attach_function :album_artist, [ Album ], Artist |
#album_cover(album, image_size) ⇒ String?
the album must be loaded, or this function always return nil.
Returns image ID to pass to #image_create, or nil if the album has no image.
31 |
# File 'lib/spotify/api/album.rb', line 31 attach_function :album_cover, [ Album, :image_size ], ImageID |
#album_is_available(album) ⇒ Boolean
the album must be loaded, or this function always return false.
Returns true if the album is available for playback.
15 |
# File 'lib/spotify/api/album.rb', line 15 attach_function :album_is_available, [ Album ], :bool |
#album_is_loaded(album) ⇒ Boolean
Returns true if the album is populated with data.
8 |
# File 'lib/spotify/api/album.rb', line 8 attach_function :album_is_loaded, [ Album ], :bool |
#album_name(album) ⇒ String
the album must be loaded, or this function always return an empty string.
Returns name of the album.
38 |
# File 'lib/spotify/api/album.rb', line 38 attach_function :album_name, [ Album ], UTF8String |
#album_type(album) ⇒ Symbol
the album must be loaded, or this function always return :unknown.
Returns album type, one of :album, :single, :compilation, :unknown.
52 |
# File 'lib/spotify/api/album.rb', line 52 attach_function :album_type, [ Album ], :albumtype |
#album_year(album) ⇒ String
the album must be loaded, or this function always return 0.
Returns release year of the album.
45 |
# File 'lib/spotify/api/album.rb', line 45 attach_function :album_year, [ Album ], :int |
#albumbrowse_album(album_browse) ⇒ Album?
the album browse request must have completed, or this function always return nil.
Returns the album being browsed.
36 |
# File 'lib/spotify/api/album_browse.rb', line 36 attach_function :albumbrowse_album, [ AlbumBrowse ], Album |
#albumbrowse_artist(album_browse) ⇒ Artist?
the album browse request must have completed, or this function always return nil.
Returns the authoring artist of the album being browsed.
43 |
# File 'lib/spotify/api/album_browse.rb', line 43 attach_function :albumbrowse_artist, [ AlbumBrowse ], Artist |
#albumbrowse_backend_request_duration(album_browse) ⇒ Integer
the album browse request must have completed, or this function will return an undefined value.
Returns the time (in ms) that was spent waiting for the Spotify backend to serve the request, -1 if served from local cache.
91 |
# File 'lib/spotify/api/album_browse.rb', line 91 attach_function :albumbrowse_backend_request_duration, [ AlbumBrowse ], :int |
#albumbrowse_copyright(album_browse, index) ⇒ String?
if index is out of range, returns nil.
Returns the copyright string at index.
60 |
# File 'lib/spotify/api/album_browse.rb', line 60 attach_function :albumbrowse_copyright, [ AlbumBrowse, :int ], UTF8String |
#albumbrowse_create(session, album, albumbrowse_complete_callback, userdata) ⇒ AlbumBrowse
make very sure the callback proc is not garbage collected before it is called!
Returns a request for browsing an album.
19 |
# File 'lib/spotify/api/album_browse.rb', line 19 attach_function :albumbrowse_create, [ Session, Album, :albumbrowse_complete_cb, :userdata ], AlbumBrowse |
#albumbrowse_error(album_browse) ⇒ Symbol
Returns album browsing error code.
29 |
# File 'lib/spotify/api/album_browse.rb', line 29 attach_function :albumbrowse_error, [ AlbumBrowse ], APIError |
#albumbrowse_is_loaded(album_browse) ⇒ Boolean
Returns true if the album browse request has completed.
24 |
# File 'lib/spotify/api/album_browse.rb', line 24 attach_function :albumbrowse_is_loaded, [ AlbumBrowse ], :bool |
#albumbrowse_num_copyrights(album_browse) ⇒ Integer
the album browse request must have completed, or this function always return 0.
Returns number of copyright strings on the album being browsed.
51 |
# File 'lib/spotify/api/album_browse.rb', line 51 attach_function :albumbrowse_num_copyrights, [ AlbumBrowse ], :int |
#albumbrowse_num_tracks(album_browse) ⇒ Integer
the album browse request must have completed, or this function always return 0.
Returns number of tracks on the album being browsed.
68 |
# File 'lib/spotify/api/album_browse.rb', line 68 attach_function :albumbrowse_num_tracks, [ AlbumBrowse ], :int |
#albumbrowse_review(album_browse) ⇒ String
the album browse request must have completed, or this function always return an empty string.
Returns the review for the album being browsed.
84 |
# File 'lib/spotify/api/album_browse.rb', line 84 attach_function :albumbrowse_review, [ AlbumBrowse ], UTF8String |
#albumbrowse_track(album_browse, index) ⇒ Track?
if index is out of range, returns nil.
Returns the track at index.
77 |
# File 'lib/spotify/api/album_browse.rb', line 77 attach_function :albumbrowse_track, [ AlbumBrowse, :int ], Track |
#artist_is_loaded(artist) ⇒ Boolean
Returns true if the artist is populated with data.
15 |
# File 'lib/spotify/api/artist.rb', line 15 attach_function :artist_is_loaded, [ Artist ], :bool |
#artist_name(artist) ⇒ String
the artist must be loaded, or this function always return an empty string.
Returns name of the artist.
10 |
# File 'lib/spotify/api/artist.rb', line 10 attach_function :artist_name, [ Artist ], UTF8String |
#artist_portrait(artist, image_size) ⇒ String?
the artist must be loaded, or this function always return nil.
Returns image ID to pass to #image_create, or nil if the artist has no image.
24 |
# File 'lib/spotify/api/artist.rb', line 24 attach_function :artist_portrait, [ Artist, :image_size ], ImageID |
#artistbrowse_album(artist_browse, index) ⇒ Track?
if index is out of range, returns nil.
Returns the album at index.
88 |
# File 'lib/spotify/api/artist_browse.rb', line 88 attach_function :artistbrowse_album, [ ArtistBrowse, :int ], Album |
#artistbrowse_artist(artist_browse) ⇒ Artist?
the artist browse request must have completed, or this function always return nil.
Returns the artist being browsed.
37 |
# File 'lib/spotify/api/artist_browse.rb', line 37 attach_function :artistbrowse_artist, [ ArtistBrowse ], Artist |
#artistbrowse_backend_request_duration(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function will return an undefined value.
Returns the time (in ms) that was spent waiting for the Spotify backend to serve the request, -1 if served from local cache.
119 |
# File 'lib/spotify/api/artist_browse.rb', line 119 attach_function :artistbrowse_backend_request_duration, [ ArtistBrowse ], :int |
#artistbrowse_biography(artist_browse) ⇒ String
the artist browse request must have completed, or this function always return an empty string.
Returns the review for the artist being browsed.
112 |
# File 'lib/spotify/api/artist_browse.rb', line 112 attach_function :artistbrowse_biography, [ ArtistBrowse ], UTF8String |
#artistbrowse_create(session, artist, type, callback, userdata) ⇒ ArtistBrowse
make very sure the callback proc is not garbage collected before it is called!
Returns a request for browsing an artist.
20 |
# File 'lib/spotify/api/artist_browse.rb', line 20 attach_function :artistbrowse_create, [ Session, Artist, :artistbrowse_type, :artistbrowse_complete_cb, :userdata ], ArtistBrowse |
#artistbrowse_error(artist_browse) ⇒ Symbol
Returns artist browsing error code.
30 |
# File 'lib/spotify/api/artist_browse.rb', line 30 attach_function :artistbrowse_error, [ ArtistBrowse ], APIError |
#artistbrowse_is_loaded(artist_browse) ⇒ Boolean
Returns true if the artist browse request has completed.
25 |
# File 'lib/spotify/api/artist_browse.rb', line 25 attach_function :artistbrowse_is_loaded, [ ArtistBrowse ], :bool |
#artistbrowse_num_albums(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function always return 0.
Returns number of artist albums.
79 |
# File 'lib/spotify/api/artist_browse.rb', line 79 attach_function :artistbrowse_num_albums, [ ArtistBrowse ], :int |
#artistbrowse_num_portraits(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function always return 0.
Returns number of artist portraits.
45 |
# File 'lib/spotify/api/artist_browse.rb', line 45 attach_function :artistbrowse_num_portraits, [ ArtistBrowse ], :int |
#artistbrowse_num_similar_artists(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function always return 0.
Returns number of similar artists.
96 |
# File 'lib/spotify/api/artist_browse.rb', line 96 attach_function :artistbrowse_num_similar_artists, [ ArtistBrowse ], :int |
#artistbrowse_num_tophit_tracks(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function always return 0.
Returns number of tophit tracks.
127 |
# File 'lib/spotify/api/artist_browse.rb', line 127 attach_function :artistbrowse_num_tophit_tracks, [ ArtistBrowse ], :int |
#artistbrowse_num_tracks(artist_browse) ⇒ Integer
the artist browse request must have completed, or this function always return 0.
Returns number of artist tracks.
62 |
# File 'lib/spotify/api/artist_browse.rb', line 62 attach_function :artistbrowse_num_tracks, [ ArtistBrowse ], :int |
#artistbrowse_portrait(artist_browse, index) ⇒ String?
if index is out of range, returns nil.
Returns image ID to pass to #image_create.
54 |
# File 'lib/spotify/api/artist_browse.rb', line 54 attach_function :artistbrowse_portrait, [ ArtistBrowse, :int ], ImageID |
#artistbrowse_similar_artist(artist_browse, index) ⇒ Track?
if index is out of range, returns nil.
Returns a similar artist at index.
105 |
# File 'lib/spotify/api/artist_browse.rb', line 105 attach_function :artistbrowse_similar_artist, [ ArtistBrowse, :int ], Artist |
#artistbrowse_tophit_track(artist_browse, index) ⇒ Track?
if index is out of range, returns nil.
Returns the tophit track at index.
136 |
# File 'lib/spotify/api/artist_browse.rb', line 136 attach_function :artistbrowse_tophit_track, [ ArtistBrowse, :int ], Track |
#artistbrowse_track(artist_browse, index) ⇒ Track?
if index is out of range, returns nil.
Returns the track at index.
71 |
# File 'lib/spotify/api/artist_browse.rb', line 71 attach_function :artistbrowse_track, [ ArtistBrowse, :int ], Track |
#build_id ⇒ String
Returns libspotify build ID.
8 |
# File 'lib/spotify/api/miscellaneous.rb', line 8 attach_function :build_id, [], UTF8String |
#error_message(error) ⇒ String
Returns explanatory error message for an error code.
8 |
# File 'lib/spotify/api/error.rb', line 8 attach_function :error_message, [ APIError ], UTF8String |
#image_add_load_callback(image, callback, userdata) ⇒ Symbol
make very sure the callback proc is not garbage collected before it is called!
Add a callback that will be invoked when the image is loaded.
20 |
# File 'lib/spotify/api/image.rb', line 20 attach_function :image_add_load_callback, [ Image, :image_loaded_cb, :userdata ], APIError |
#image_create(session, image_id) ⇒ Image
Returns image from an image id.
9 |
# File 'lib/spotify/api/image.rb', line 9 attach_function :image_create, [ Session, ImageID ], Image |
#image_create_from_link(session, link) ⇒ Image?
Returns image pointed to by link, or nil if link is not a valid image link.
77 |
# File 'lib/spotify/api/image.rb', line 77 attach_function :image_create_from_link, [ Session, Link ], Image |
#image_data(image) ⇒ String?
the image must be loaded, or this function always return nil.
Retrieves raw image data.
60 61 62 63 64 65 66 |
# File 'lib/spotify/api/image.rb', line 60 attach_function :image_data, [ Image, :buffer_out ], :pointer do |image| with_buffer(:size_t, clear: true) do |image_size_buffer| data = sp_image_data(image, image_size_buffer) image_size = image_size_buffer.read_size_t data.read_bytes(image_size) if image_size > 0 end end |
#image_error(image) ⇒ Symbol
Returns image error code.
41 |
# File 'lib/spotify/api/image.rb', line 41 attach_function :image_error, [ Image ], APIError |
#image_format(image) ⇒ Symbol
the image must be loaded, or this function always return :unknown.
Returns image format, one of :unknown, or :jpeg.
48 |
# File 'lib/spotify/api/image.rb', line 48 attach_function :image_format, [ Image ], :imageformat |
#image_image_id(image) ⇒ String
Returns image id.
71 |
# File 'lib/spotify/api/image.rb', line 71 attach_function :image_image_id, [ Image ], ImageID |
#image_is_loaded(image) ⇒ Boolean
Images that don’t exist in Spotify can also return true.
Returns true if the image information has been retrieved.
36 |
# File 'lib/spotify/api/image.rb', line 36 attach_function :image_is_loaded, [ Image ], :bool |
#image_remove_load_callback(image, callback, userdata) ⇒ Symbol
Remove an image load callback previously added with #image_add_load_callback.
30 |
# File 'lib/spotify/api/image.rb', line 30 attach_function :image_remove_load_callback, [ Image, :image_loaded_cb, :userdata ], APIError |
#inbox_error(inbox) ⇒ Symbol
Returns error status of inbox post.
33 |
# File 'lib/spotify/api/inbox.rb', line 33 attach_function :inbox_error, [ Inbox ], APIError |
#inbox_post_tracks(session, username, tracks, message, callback, userdata) ⇒ Inbox
Post an array of tracks to a Spotify user’s inbox.
21 22 23 24 25 26 27 28 |
# File 'lib/spotify/api/inbox.rb', line 21 attach_function :inbox_post_tracks, [ Session, UTF8String, :array, :int, UTF8String, :inboxpost_complete_cb, :userdata ], Inbox do |session, username, tracks, , callback, userdata| tracks = Array(tracks) with_buffer(Spotify::Track, size: tracks.length) do |tracks_buffer| tracks_buffer.write_array_of_pointer(tracks) sp_inbox_post_tracks(session, username, tracks_buffer, tracks.length, , callback, userdata) end end |
#link_as_album(link) ⇒ Album?
Returns album pointed to by the link, or nil if not an album.
123 |
# File 'lib/spotify/api/link.rb', line 123 attach_function :link_as_album, [ Link ], Album |
#link_as_artist(link) ⇒ Artist?
Returns artist pointed to by the link, or nil if not an artist.
128 |
# File 'lib/spotify/api/link.rb', line 128 attach_function :link_as_artist, [ Link ], Artist |
#link_as_string(link) ⇒ String
Retrieve string representation of link.
87 88 89 90 91 92 |
# File 'lib/spotify/api/link.rb', line 87 attach_function :link_as_string, [ Link, :buffer_out, :int ], :int do |link| link_length = sp_link_as_string(link, nil, 0) with_string_buffer(link_length) do |string_buffer, size| sp_link_as_string(link, string_buffer, size) end end |
#link_as_track(link) ⇒ Track?
Returns track pointed to by the link, or nil if not a track.
102 |
# File 'lib/spotify/api/link.rb', line 102 attach_function :link_as_track, [ Link ], Track |
#link_as_track_and_offset(link) ⇒ Array<Track, Integer>?
if the link is not a track link, this method returns nil.
if no track offset is available in the link, the offset out will always be set to 0.
Returns track and offset (in ms) as a tuple, or nil.
113 114 115 116 117 118 |
# File 'lib/spotify/api/link.rb', line 113 attach_function :link_as_track_and_offset, [ Link, :buffer_out ], Track do |link| with_buffer(:int) do |offset_buffer| track = sp_link_as_track_and_offset(link, offset_buffer) [track, offset_buffer.read_int] if track end end |
#link_as_user(link) ⇒ User?
Returns user pointed to by the link, or nil if not a user.
133 |
# File 'lib/spotify/api/link.rb', line 133 attach_function :link_as_user, [ Link ], User |
#link_create_from_album(album) ⇒ Link?
21 |
# File 'lib/spotify/api/link.rb', line 21 attach_function :link_create_from_album, [ Album ], Link |
#link_create_from_album_cover(album, image_size) ⇒ Link?
55 |
# File 'lib/spotify/api/link.rb', line 55 attach_function :link_create_from_album_cover, [ Album, :image_size ], Link |
#link_create_from_artist(artist) ⇒ Link?
26 |
# File 'lib/spotify/api/link.rb', line 26 attach_function :link_create_from_artist, [ Artist ], Link |
#link_create_from_artist_portrait(artist, image_size) ⇒ Link?
42 |
# File 'lib/spotify/api/link.rb', line 42 attach_function :link_create_from_artist_portrait, [ Artist, :image_size ], Link |
#link_create_from_artistbrowse_portrait(artist_browse, index) ⇒ Link?
49 |
# File 'lib/spotify/api/link.rb', line 49 attach_function :link_create_from_artistbrowse_portrait, [ ArtistBrowse, :int ], Link |
#link_create_from_image(image) ⇒ Link
72 |
# File 'lib/spotify/api/link.rb', line 72 attach_function :link_create_from_image, [ Image ], Link |
#link_create_from_playlist(playlist) ⇒ Link?
36 |
# File 'lib/spotify/api/link.rb', line 36 attach_function :link_create_from_playlist, [ Playlist ], Link |
#link_create_from_search(search) ⇒ Link?
31 |
# File 'lib/spotify/api/link.rb', line 31 attach_function :link_create_from_search, [ Search ], Link |
#link_create_from_string(spotify_uri) ⇒ Link
Create a Link from a Spotify URI or Spotify HTTP URL.
10 |
# File 'lib/spotify/api/link.rb', line 10 attach_function :link_create_from_string, [ BestEffortString ], Link |
#link_create_from_track(track, offset) ⇒ Link?
16 |
# File 'lib/spotify/api/link.rb', line 16 attach_function :link_create_from_track, [ Track, :int ], Link |
#link_create_from_user(user) ⇒ Link
77 |
# File 'lib/spotify/api/link.rb', line 77 attach_function :link_create_from_user, [ User ], Link |
#link_type(link) ⇒ Symbol
Returns type of link, one of :invalid, :track, :album, :artist, :search, :playlist, :profile, :starred, :localtrack, :image.
97 |
# File 'lib/spotify/api/link.rb', line 97 attach_function :link_type, [ Link ], :linktype |
#localtrack_create(artist, title, album, duration) ⇒ Track
Create a local Track reference, whatever that means.
151 |
# File 'lib/spotify/api/track.rb', line 151 attach_function :localtrack_create, [ UTF8String, UTF8String, UTF8String, :int ], Track |
#offline_num_playlists(session) ⇒ Integer
Returns total number of playlists marked for offline synchronization.
275 |
# File 'lib/spotify/api/session.rb', line 275 attach_function :offline_num_playlists, [ Session ], :int |
#offline_sync_get_status(session, offline_sync_status) ⇒ Boolean
Returns true if offline synching is enabled.
286 |
# File 'lib/spotify/api/session.rb', line 286 attach_function :offline_sync_get_status, [ Session, OfflineSyncStatus.by_ref ], :bool |
#offline_time_left(session) ⇒ Integer
Returns remaining time (in seconds) until offline key store expires and user is required to relogin.
291 |
# File 'lib/spotify/api/session.rb', line 291 attach_function :offline_time_left, [ Session ], :int |
#offline_tracks_to_sync(session) ⇒ Integer
Returns total number of tracks left to sync before all offline content has downloaded.
270 |
# File 'lib/spotify/api/session.rb', line 270 attach_function :offline_tracks_to_sync, [ Session ], :int |
#playlist_add_callbacks(playlist, playlist_callbacks, userdata) ⇒ Symbol
it is very important that the callbacks are not garbage collected before they are called!
Attach callbacks to the playlist, used for getting change notifications.
27 |
# File 'lib/spotify/api/playlist.rb', line 27 attach_function :playlist_add_callbacks, [ Playlist, PlaylistCallbacks.by_ref, :userdata ], APIError |
#playlist_add_tracks(playlist, tracks, offset, session) ⇒ Symbol
if the playlist is not loaded, the function always return an error.
Add tracks to the playlist.
202 203 204 205 206 207 208 209 |
# File 'lib/spotify/api/playlist.rb', line 202 attach_function :playlist_add_tracks, [ Playlist, :array, :int, :int, Session ], APIError do |playlist, tracks, offset, session| tracks = Array(tracks) with_buffer(Spotify::Track, size: tracks.length) do |tracks_buffer| tracks_buffer.write_array_of_pointer(tracks) sp_playlist_add_tracks(playlist, tracks_buffer, tracks.length, offset, session) end end |
#playlist_create(session, link) ⇒ Playlist?
Instantiate a Playlist from a Link.
313 |
# File 'lib/spotify/api/playlist.rb', line 313 attach_function :playlist_create, [ Session, Link ], Playlist |
#playlist_get_description(playlist) ⇒ String?
if the playlist is not loaded, the function always return nil.
Returns playlist description, if available.
157 |
# File 'lib/spotify/api/playlist.rb', line 157 attach_function :playlist_get_description, [ Playlist ], UTF8String |
#playlist_get_image(playlist) ⇒ String?
if the playlist is not loaded, the function always return nil.
Retrieve playlist image ID as a string.
170 171 172 173 174 175 176 |
# File 'lib/spotify/api/playlist.rb', line 170 attach_function :playlist_get_image, [ Playlist, :buffer_out ], :bool do |playlist| with_buffer(Spotify::ImageID) do |image_id_buffer| if sp_playlist_get_image(playlist, image_id_buffer) ImageID.from_native(image_id_buffer, nil) end end end |
#playlist_get_offline_download_completed(session, playlist) ⇒ Integer
if the playlist is not loaded, the function always return 0.
if the playlist is not marked for offline download, the function always return 0.
Returns percentage of playlist downloaded, 0..100.
330 |
# File 'lib/spotify/api/playlist.rb', line 330 attach_function :playlist_get_offline_download_completed, [ Session, Playlist ], :int |
#playlist_get_offline_status(session, playlist) ⇒ Symbol
if the playlist is not loaded, the function always return :no.
Returns playlist offline status, one of :no, :yes, :downloading, or :waiting.
322 |
# File 'lib/spotify/api/playlist.rb', line 322 attach_function :playlist_get_offline_status, [ Session, Playlist ], :playlist_offline_status |
#playlist_has_pending_changes(playlist) ⇒ Boolean
if the playlist is not loaded, the function always return true.
Returns true if the playlist has local changes that have not yet been acknowledged by Spotify backend.
183 |
# File 'lib/spotify/api/playlist.rb', line 183 attach_function :playlist_has_pending_changes, [ Playlist ], :bool |
#playlist_is_collaborative(playlist) ⇒ Boolean
if #playlist_set_collaborative was used, the final value will not be visible until after libspotify has negotiated with Spotify backend.
if playlist is not loaded, the function always return false.
Returns true if the playlist is collaborative, i.e. editable by others.
128 |
# File 'lib/spotify/api/playlist.rb', line 128 attach_function :playlist_is_collaborative, [ Playlist ], :bool |
#playlist_is_in_ram(session, playlist) ⇒ Boolean
Returns true if playlist is loaded in memory, as opposed to only stored on disk.
295 |
# File 'lib/spotify/api/playlist.rb', line 295 attach_function :playlist_is_in_ram, [ Session, Playlist ], :bool |
#playlist_is_loaded(playlist) ⇒ Boolean
Returns true if playlist is loaded.
8 |
# File 'lib/spotify/api/playlist.rb', line 8 attach_function :playlist_is_loaded, [ Playlist ], :bool |
#playlist_name(playlist) ⇒ String
if playlist is not loaded, the function always return an empty string.
Returns name of the playlist.
103 |
# File 'lib/spotify/api/playlist.rb', line 103 attach_function :playlist_name, [ Playlist ], UTF8String |
#playlist_num_subscribers(playlist) ⇒ Integer
if the playlist is not loaded, the function always return 0.
if #playlist_update_subscribers have not been called, the function always return 0.
Returns number of playlist subscribers.
264 |
# File 'lib/spotify/api/playlist.rb', line 264 attach_function :playlist_num_subscribers, [ Playlist ], :uint |
#playlist_num_tracks(playlist) ⇒ Integer
if playlist is not loaded, the function always return 0.
Returns number of tracks in the playlist.
44 |
# File 'lib/spotify/api/playlist.rb', line 44 attach_function :playlist_num_tracks, [ Playlist ], :int |
#playlist_owner(playlist) ⇒ User
Returns owner of the playlist.
118 |
# File 'lib/spotify/api/playlist.rb', line 118 attach_function :playlist_owner, [ Playlist ], User |
#playlist_remove_callbacks(playlist, playlist_callbacks, userdata) ⇒ Symbol
Remove playlist callbacks previously added with #playlist_add_callbacks.
37 |
# File 'lib/spotify/api/playlist.rb', line 37 attach_function :playlist_remove_callbacks, [ Playlist, PlaylistCallbacks.by_ref, :userdata ], APIError |
#playlist_remove_tracks(playlist, indices) ⇒ Symbol
if the playlist is not loaded, the function always return an error.
any index in indices_pointer must exist at most once, i.e. [0,1,2] is valid, [0,0,1] is not.
Remove tracks from the playlist at the given indices.
226 227 228 229 230 231 232 233 |
# File 'lib/spotify/api/playlist.rb', line 226 attach_function :playlist_remove_tracks, [ Playlist, :array, :int ], APIError do |playlist, indices| indices = Array(indices) with_buffer(:int, size: indices.length) do |indices_buffer| indices_buffer.write_array_of_int(indices) sp_playlist_remove_tracks(playlist, indices_buffer, indices.length) end end |
#playlist_rename(playlist, new_name) ⇒ Symbol
if playlist is not loaded, the function always return :permission_denied.
Rename the playlist.
113 |
# File 'lib/spotify/api/playlist.rb', line 113 attach_function :playlist_rename, [ Playlist, UTF8String ], APIError |
#playlist_reorder_tracks(playlist, indices, index) ⇒ Symbol
if the playlist is not loaded, the function always return an error.
any index in indices_pointer must exist at most once, i.e. [0,1,2] is valid, [0,0,1] is not.
Move tracks at the given indices to position index and forward.
248 249 250 251 252 253 254 255 |
# File 'lib/spotify/api/playlist.rb', line 248 attach_function :playlist_reorder_tracks, [ Playlist, :array, :int, :int ], APIError do |playlist, indices, index| indices = Array(indices) with_buffer(:int, size: indices.length) do |indices_buffer| indices_buffer.write_array_of_int(indices) sp_playlist_reorder_tracks(playlist, indices_buffer, indices.length, index) end end |
#playlist_set_autolink_tracks(playlist, autolink) ⇒ Symbol
the function always return :ok.
Set autolinking state for a playlist.
If a playlist is set to autolink, unplayable tracks will be made playable by linking them to an equivalent playable track when possible.
150 |
# File 'lib/spotify/api/playlist.rb', line 150 attach_function :playlist_set_autolink_tracks, [ Playlist, :bool ], APIError |
#playlist_set_collaborative(playlist, collaborative) ⇒ Symbol
the function always return :ok.
Set collaborative status on a playlist.
138 |
# File 'lib/spotify/api/playlist.rb', line 138 attach_function :playlist_set_collaborative, [ Playlist, :bool ], APIError |
#playlist_set_in_ram(session, playlist, in_ram) ⇒ Symbol
Set if playlist should be loaded into memory, as opposed to only read from on disk.
305 |
# File 'lib/spotify/api/playlist.rb', line 305 attach_function :playlist_set_in_ram, [ Session, Playlist, :bool ], APIError |
#playlist_set_offline_mode(session, playlist, offline) ⇒ Symbol
Set if playlist should be marked for offline playback.
339 |
# File 'lib/spotify/api/playlist.rb', line 339 attach_function :playlist_set_offline_mode, [ Session, Playlist, :bool ], APIError |
#playlist_subscribers(playlist) ⇒ Subscribers
if the playlist is not loaded, the function always return an empty structure.
if #playlist_update_subscribers have not been called, the function always return an empty structure.
278 |
# File 'lib/spotify/api/playlist.rb', line 278 attach_function :playlist_subscribers, [ Playlist ], Subscribers.auto_ptr |
#playlist_track(playlist, index) ⇒ Track?
if index is out of range, the function always return nil.
Returns track at index.
52 |
# File 'lib/spotify/api/playlist.rb', line 52 attach_function :playlist_track, [ Playlist, :int ], Track |
#playlist_track_create_time(playlist, index) ⇒ Integer
if index is out of range, the function always return -1.
Returns time in seconds since unix epoch that track was added at index in the playlist.
60 |
# File 'lib/spotify/api/playlist.rb', line 60 attach_function :playlist_track_create_time, [ Playlist, :int ], :int |
#playlist_track_creator(playlist, index) ⇒ User?
if index is out of range, the function always return nil.
Returns user that added the track at index in the playlist.
68 |
# File 'lib/spotify/api/playlist.rb', line 68 attach_function :playlist_track_creator, [ Playlist, :int ], User |
#playlist_track_message(playlist, index) ⇒ String
if index is out of range, the function always return nil.
Returns message attached to a playlist item.
96 |
# File 'lib/spotify/api/playlist.rb', line 96 attach_function :playlist_track_message, [ Playlist, :int ], UTF8String |
#playlist_track_seen(playlist, index) ⇒ Boolean
if index is out of range, the function always return false.
Returns true if playlist has been marked as seen with #playlist_track_set_seen.
77 |
# File 'lib/spotify/api/playlist.rb', line 77 attach_function :playlist_track_seen, [ Playlist, :int ], :bool |
#playlist_track_set_seen(playlist, index, seen) ⇒ Symbol
Set seen flag on track. The flag can be retrieved by #playlist_track_seen.
88 |
# File 'lib/spotify/api/playlist.rb', line 88 attach_function :playlist_track_set_seen, [ Playlist, :int, :bool ], APIError |
#playlist_update_subscribers(session, playlist) ⇒ Symbol
the function updates subscribers asynchronously, see PlaylistCallbacks#subscribers_changed for callback.
Request download of the subscribers list.
288 |
# File 'lib/spotify/api/playlist.rb', line 288 attach_function :playlist_update_subscribers, [ Session, Playlist ], APIError |
#playlistcontainer_add_callbacks(container, container_callbacks, userdata) ⇒ Symbol
it is very important that the callbacks are not garbage collected before they are called!
Attach callbacks to the container, used for getting change notifications.
19 |
# File 'lib/spotify/api/playlist_container.rb', line 19 attach_function :playlistcontainer_add_callbacks, [ PlaylistContainer, PlaylistContainerCallbacks.by_ref, :userdata ], APIError |
#playlistcontainer_add_folder(container, index, folder_name) ⇒ Object
you cannot rename folders, if you want to do so you have to destroy the folder and recreate it
Create a new folder in the container.
This creates a start_folder marker, and an end_folder marker right after it, at specified index.
134 |
# File 'lib/spotify/api/playlist_container.rb', line 134 attach_function :playlistcontainer_add_folder, [ PlaylistContainer, :int, UTF8String ], APIError |
#playlistcontainer_add_new_playlist(container, playlist_name) ⇒ Playlist?
the name must not constist of only spaces, and it must be shorter than 256 bytes.
Add a new playlist to the end of the container.
91 |
# File 'lib/spotify/api/playlist_container.rb', line 91 attach_function :playlistcontainer_add_new_playlist, [ PlaylistContainer, UTF8String ], Playlist |
#playlistcontainer_add_playlist(container, link) ⇒ Playlist?
Add an existing playlist to the end of the container.
99 |
# File 'lib/spotify/api/playlist_container.rb', line 99 attach_function :playlistcontainer_add_playlist, [ PlaylistContainer, Link ], Playlist |
#playlistcontainer_clear_unseen_tracks(container, playlist) ⇒ Integer
Clear unseen tracks for a playlist on a container
This will cause the next#playlistcontainer_get_unseen_tracks call to return 0.
177 |
# File 'lib/spotify/api/playlist_container.rb', line 177 attach_function :playlistcontainer_clear_unseen_tracks, [ PlaylistContainer, Playlist ], :int |
#playlistcontainer_get_unseen_tracks(container, playlist) ⇒ Array<Track>
if the playlist is not in the container, this function always return an empty array.
Number of new tracks in playlist since #playlistcontainer_clear_unseen_tracks was called.
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/spotify/api/playlist_container.rb', line 157 attach_function :playlistcontainer_get_unseen_tracks, [ PlaylistContainer, Playlist, :array, :int ], :int do |container, playlist| count = sp_playlistcontainer_get_unseen_tracks(container, playlist, nil, 0) tracks = with_buffer(Spotify::Track, size: count) do |tracks_buffer| sp_playlistcontainer_get_unseen_tracks(container, playlist, tracks_buffer, count) tracks_buffer.read_array_of_pointer(count).map do |pointer| Spotify::Track.retaining_class.from_native(pointer, nil) end end tracks || [] end |
#playlistcontainer_is_loaded(container) ⇒ Boolean
Returns true if the container is loaded.
144 |
# File 'lib/spotify/api/playlist_container.rb', line 144 attach_function :playlistcontainer_is_loaded, [ PlaylistContainer ], :bool |
#playlistcontainer_move_playlist(container, index, new_position, dry_run) ⇒ Symbol
if the index is out of range, the function always return an error.
Move a playlist to another position in the container.
122 |
# File 'lib/spotify/api/playlist_container.rb', line 122 attach_function :playlistcontainer_move_playlist, [ PlaylistContainer, :int, :int, :bool ], APIError |
#playlistcontainer_num_playlists(container) ⇒ Integer
if the container is not loaded, the function will always return 0.
Returns number of playlists in container.
37 |
# File 'lib/spotify/api/playlist_container.rb', line 37 attach_function :playlistcontainer_num_playlists, [ PlaylistContainer ], :int |
#playlistcontainer_owner(container) ⇒ User
Returns owner of the container.
139 |
# File 'lib/spotify/api/playlist_container.rb', line 139 attach_function :playlistcontainer_owner, [ PlaylistContainer ], User |
#playlistcontainer_playlist(container) ⇒ Playlist?
if index is out of range, the function always return nil.
Returns playlist at index.
45 |
# File 'lib/spotify/api/playlist_container.rb', line 45 attach_function :playlistcontainer_playlist, [ PlaylistContainer, :int ], Playlist |
#playlistcontainer_playlist_folder_id(container, index) ⇒ Integer
if the index is out of range, the function always return 0.
Returns folder id at index.
82 |
# File 'lib/spotify/api/playlist_container.rb', line 82 attach_function :playlistcontainer_playlist_folder_id, [ PlaylistContainer, :int ], :uint64 |
#playlistcontainer_playlist_folder_name(container, index) ⇒ String?
the spotify client appear to constrain the name to 255 chars, so this function does too.
if index is out of range, the function always return nil.
Retrieve folder name of a folder in a container.
69 70 71 72 73 74 75 |
# File 'lib/spotify/api/playlist_container.rb', line 69 attach_function :playlistcontainer_playlist_folder_name, [ PlaylistContainer, :int, :buffer_out, :int ], APIError do |container, index| folder_name = with_string_buffer(255) do |folder_name_buffer, size| sp_playlistcontainer_playlist_folder_name(container, index, folder_name_buffer, size) end folder_name unless folder_name.empty? end |
#playlistcontainer_playlist_type(container, index) ⇒ Symbol
if index is out of range, the function always return :playlist.
Returns playlist type of playlist at index, one of :playlist, :start_folder, :end_folder, :placeholder.
53 |
# File 'lib/spotify/api/playlist_container.rb', line 53 attach_function :playlistcontainer_playlist_type, [ PlaylistContainer, :int ], :playlist_type |
#playlistcontainer_remove_callbacks(container, container_callbacks, userdata) ⇒ Symbol
Remove container callbacks previously added with #playlistcontainer_add_callbacks.
29 |
# File 'lib/spotify/api/playlist_container.rb', line 29 attach_function :playlistcontainer_remove_callbacks, [ PlaylistContainer, PlaylistContainerCallbacks.by_ref, :userdata ], APIError |
#playlistcontainer_remove_playlist(container, index) ⇒ Symbol
if you remove a folder marker, remove the other corresponding (start or stop) marker as well, or the playlist will be left in an inconsistent state.
if the index is out of range, the function always return an error.
Remove a playlist from a container.
111 |
# File 'lib/spotify/api/playlist_container.rb', line 111 attach_function :playlistcontainer_remove_playlist, [ PlaylistContainer, :int ], APIError |
#search_album(search, index) ⇒ Album?
if index is out of range, the function always return nil.
Returns album at index.
85 |
# File 'lib/spotify/api/search.rb', line 85 attach_function :search_album, [ Search, :int ], Album |
#search_artist(search, index) ⇒ Artist?
if index is out of range, the function always return nil.
Returns artist at index.
103 |
# File 'lib/spotify/api/search.rb', line 103 attach_function :search_artist, [ Search, :int ], Artist |
#search_create(session, query, track_offset, track_count, album_offset, album_count, artist_offset, artist_count, playlist_offset, playlist_count, search_type, callback, userdata) ⇒ Search
it is very important that the callback is not garbage collected before it is called!
Fire off a search query for tracks, albums, artists, and playlists.
27 |
# File 'lib/spotify/api/search.rb', line 27 attach_function :search_create, [ Session, UTF8String, :int, :int, :int, :int, :int, :int, :int, :int, :search_type, :search_complete_cb, :userdata ], Search |
#search_did_you_mean(search) ⇒ String
if the search is not loaded, the function always return an empty string.
Returns spotify’s guess at what the query might have meant instead.
49 |
# File 'lib/spotify/api/search.rb', line 49 attach_function :search_did_you_mean, [ Search ], UTF8String |
#search_error(search) ⇒ Symbol
Returns error code.
37 |
# File 'lib/spotify/api/search.rb', line 37 attach_function :search_error, [ Search ], APIError |
#search_is_loaded(search) ⇒ Boolean
Returns true if the search has completed.
32 |
# File 'lib/spotify/api/search.rb', line 32 attach_function :search_is_loaded, [ Search ], :bool |
#search_num_albums(search) ⇒ Integer
if #search_total_albums is larger than this number, you may retrieve additional results if you make the same search query again, but with a higher album_offset
if the search is not loaded, the function always return 0.
Returns number of albums in the search result.
77 |
# File 'lib/spotify/api/search.rb', line 77 attach_function :search_num_albums, [ Search ], :int |
#search_num_artists(search) ⇒ Integer
if #search_total_artists is larger than this number, you may retrieve additional results if you make the same search query again, but with a higher artist_offset
if the search is not loaded, the function always return 0.
Returns number of artists in the search result.
95 |
# File 'lib/spotify/api/search.rb', line 95 attach_function :search_num_artists, [ Search ], :int |
#search_num_playlists(search) ⇒ Integer
if #search_total_playlists is larger than this number, you may retrieve additional results if you make the same search query again, but with a higher playlist_offset
if the search is not loaded, the function always return 0.
Returns number of playlists in the search result.
113 |
# File 'lib/spotify/api/search.rb', line 113 attach_function :search_num_playlists, [ Search ], :int |
#search_num_tracks(search) ⇒ Integer
if #search_total_tracks is larger than this number, you may retrieve additional results if you make the same search query again, but with a higher track_offset
if the search is not loaded, the function always return 0.
Returns number of tracks in the search result.
59 |
# File 'lib/spotify/api/search.rb', line 59 attach_function :search_num_tracks, [ Search ], :int |
#search_playlist(search, index) ⇒ Playlist?
if index is out of range, the function always return nil.
Returns playlist at index.
121 |
# File 'lib/spotify/api/search.rb', line 121 attach_function :search_playlist, [ Search, :int ], Playlist |
#search_playlist_image_uri(search, index) ⇒ String?
if index is out of range, the function always return nil.
Returns image uri for playlist at index.
147 |
# File 'lib/spotify/api/search.rb', line 147 attach_function :search_playlist_image_uri, [ Search, :int ], UTF8String |
#search_playlist_name(search, index) ⇒ String?
if index is out of range, the function always return nil.
Returns name for playlist at index.
129 |
# File 'lib/spotify/api/search.rb', line 129 attach_function :search_playlist_name, [ Search, :int ], UTF8String |
#search_playlist_uri(search, index) ⇒ String?
if index is out of range, the function always return nil.
Returns spotify uri for playlist at index.
138 |
# File 'lib/spotify/api/search.rb', line 138 attach_function :search_playlist_uri, [ Search, :int ], UTF8String |
#search_query(search) ⇒ String
Returns search query.
42 |
# File 'lib/spotify/api/search.rb', line 42 attach_function :search_query, [ Search ], UTF8String |
#search_total_albums(search) ⇒ Integer
if the search is not loaded, the function always return 0.
Returns number of total albums in the search result.
161 |
# File 'lib/spotify/api/search.rb', line 161 attach_function :search_total_albums, [ Search ], :int |
#search_total_artists(search) ⇒ Integer
if the search is not loaded, the function always return 0.
Returns number of total artists in the search result.
168 |
# File 'lib/spotify/api/search.rb', line 168 attach_function :search_total_artists, [ Search ], :int |
#search_total_playlists(search) ⇒ Integer
if the search is not loaded, the function always return 0.
Returns number of total playlists in the search result.
175 |
# File 'lib/spotify/api/search.rb', line 175 attach_function :search_total_playlists, [ Search ], :int |
#search_total_tracks(search) ⇒ Integer
if the search is not loaded, the function always return 0.
Returns number of total tracks in the search result.
154 |
# File 'lib/spotify/api/search.rb', line 154 attach_function :search_total_tracks, [ Search ], :int |
#search_track(search, index) ⇒ Track?
if index is out of range, the function always return nil.
Returns track at index.
67 |
# File 'lib/spotify/api/search.rb', line 67 attach_function :search_track, [ Search, :int ], Track |
#session_connectionstate(session) ⇒ Symbol
Returns current session connection state, one of :logged_out, :logged_in, :disconnected, :undefined, :offline.
139 |
# File 'lib/spotify/api/session.rb', line 139 attach_function :session_connectionstate, [ Session ], :connectionstate |
#session_create(config) ⇒ Array<Symbol, Session>
it is very important that the callbacks are not garbage collected while they may be called!
Returns a tuple of error code, and session.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/spotify/api/session.rb', line 30 attach_function :session_create, [ SessionConfig.by_ref, :buffer_out ], APIError do |config| config = Spotify::SessionConfig.new(config.to_h) with_buffer(Spotify::Session) do |session_buffer| error = sp_session_create(config, session_buffer) error = nil if error == :ok session = if error.nil? Spotify::Session.from_native(session_buffer.read_pointer, nil) end [error, session] end end |
#session_flush_caches(session) ⇒ Symbol
libspotify does this periodically by itself, and on logout, so usually this is not needed.
Force libspotify to write all disk-stored data to disk immediately.
328 |
# File 'lib/spotify/api/session.rb', line 328 attach_function :session_flush_caches, [ Session ], APIError |
#session_forget_me(session) ⇒ Symbol
Forget a previously remembered user.
102 |
# File 'lib/spotify/api/session.rb', line 102 attach_function :session_forget_me, [ Session ], APIError |
#session_get_volume_normalization(session) ⇒ Boolean
Returns current volume normalization setting.
320 |
# File 'lib/spotify/api/session.rb', line 320 attach_function :session_get_volume_normalization, [ Session ], :bool |
#session_inbox_create(session) ⇒ Playlist
if not logged in, the function always return nil.
Returns inbox playlist for currently logged in user (playlist where items sent by other users are posted to).
214 |
# File 'lib/spotify/api/session.rb', line 214 attach_function :session_inbox_create, [ Session ], Playlist |
#session_is_private_session(session) ⇒ Boolean
Returns true if private session is enabled.
351 |
# File 'lib/spotify/api/session.rb', line 351 attach_function :session_is_private_session, [ Session ], :bool |
#session_is_scrobbling(session, social_provider) ⇒ Symbol
Retrieve the scrobbling state.
This makes it possible to find out if scrobbling is locally overrided or if global setting is used.
374 375 376 377 378 379 |
# File 'lib/spotify/api/session.rb', line 374 attach_function :session_is_scrobbling, [ Session, :social_provider, :buffer_out ], APIError do |session, | with_buffer(:int) do |state_buffer| error = sp_session_is_scrobbling(session, , state_buffer) enum_type(:scrobbling_state)[state_buffer.read_int] if error == :ok end end |
#session_is_scrobbling_possible(session, social_provider) ⇒ Boolean
currently this setting is only relevant to the facebook provider
Retrieve if it is possible to scrobble to the social provider.
390 391 392 393 394 395 |
# File 'lib/spotify/api/session.rb', line 390 attach_function :session_is_scrobbling_possible, [ Session, :social_provider, :buffer_out ], APIError do |session, | with_buffer(:char) do |possible_buffer| error = sp_session_is_scrobbling_possible(session, , possible_buffer) possible_buffer.read_char != 0 if error == :ok end end |
#session_login(session, username, password, remember_me, password_blob) ⇒ Symbol
Login happens in the background. You have to process events a few times before you are logged in.
Schedule a login.
80 |
# File 'lib/spotify/api/session.rb', line 80 attach_function :session_login, [ Session, UTF8String, UTF8String, :bool, UTF8String ], APIError |
#session_logout(session) ⇒ Symbol
This updates credentials in remember_me from #session_login and #session_forget_me.
Logout happen asynchronously. You need to call #session_process_events a little while.
Schedule a logout.
134 |
# File 'lib/spotify/api/session.rb', line 134 attach_function :session_logout, [ Session ], APIError |
#session_player_load(session, track) ⇒ Symbol
Load the specified track for playback.
When the the function returns, the track will have been loaded assuming there as no error.
162 |
# File 'lib/spotify/api/session.rb', line 162 attach_function :session_player_load, [ Session, Track ], APIError |
#session_player_play(session, play) ⇒ Symbol
Play or pause the currently loaded track.
This will start delivery of audio frames to the music_delivery callback in #session_create. However, playback should wait until SessionCallbacks#start_playback callback is called by libspotify.
183 |
# File 'lib/spotify/api/session.rb', line 183 attach_function :session_player_play, [ Session, :bool ], APIError |
#session_player_prefetch(session, track) ⇒ Symbol
prefetching is only possible if using a cache from config in #session_create
Tell libspotify to start preloading a track so that #session_player_load has less work to do.
This could be done towards the end of a track in a queue, before starting playing the next.
202 |
# File 'lib/spotify/api/session.rb', line 202 attach_function :session_player_prefetch, [ Session, Track ], APIError |
#session_player_seek(session, position) ⇒ Symbol
Seek to position in the currently loaded track.
171 |
# File 'lib/spotify/api/session.rb', line 171 attach_function :session_player_seek, [ Session, :int ], APIError |
#session_player_unload(session) ⇒ Symbol
Stop playback and clear the currently loaded track.
191 |
# File 'lib/spotify/api/session.rb', line 191 attach_function :session_player_unload, [ Session ], APIError |
#session_playlistcontainer(session) ⇒ PlaylistContainer?
if not logged in, the function always return nil.
Returns playlist container for currently logged in user.
208 |
# File 'lib/spotify/api/session.rb', line 208 attach_function :session_playlistcontainer, [ Session ], PlaylistContainer |
#session_preferred_bitrate(session, bitrate) ⇒ Symbol
Set preferred bitrate for music streaming.
242 |
# File 'lib/spotify/api/session.rb', line 242 attach_function :session_preferred_bitrate, [ Session, :bitrate ], APIError |
#session_preferred_offline_bitrate(session, bitrate, resync) ⇒ Symbol
Set preferred bitrate for offline playback.
306 |
# File 'lib/spotify/api/session.rb', line 306 attach_function :session_preferred_offline_bitrate, [ Session, :bitrate, :bool ], APIError |
#session_process_events(session) ⇒ Integer
Tell libspotify to process pending events from the backend.
This will download changes and updates from Spotify, while simultaneously also uploading changes made locally, such as tracks added to playlists and more.
This method is the cornerstone of libspotify. It should be called frequently to synchronize data. This method is also responsible for calling most callbacks.
61 62 63 64 65 66 |
# File 'lib/spotify/api/session.rb', line 61 attach_function :session_process_events, [ Session, :buffer_out ], APIError do |session| with_buffer(:int) do |timeout_buffer| sp_session_process_events(session, timeout_buffer) timeout_buffer.read_int end end |
#session_publishedcontainer_for_user_create(session, username) ⇒ PlaylistContainer?
if not logged in, the function always return nil.
Returns published playlists container for the specified user.
234 |
# File 'lib/spotify/api/session.rb', line 234 attach_function :session_publishedcontainer_for_user_create, [ Session, UTF8String ], PlaylistContainer |
#session_relogin(session) ⇒ Symbol
You must call #session_logout for remembered credentials to be stored.
Login happens in the background. You have to process events a few times before you are logged in.
Log in a previously remembered login from #session_login.
You would use this after terminating your application, and later starting it again, assuming #session_remembered_user contains a username that is remembered.
94 |
# File 'lib/spotify/api/session.rb', line 94 attach_function :session_relogin, [ Session ], APIError |
#session_remembered_user(session) ⇒ String?
Retrieve the remembered user from #session_login.
This is the user that will be logged in if you use #session_relogin.
114 115 116 117 118 119 120 |
# File 'lib/spotify/api/session.rb', line 114 attach_function :session_remembered_user, [ Session, :buffer_out, :size_t ], :int do |session| username_length = sp_session_remembered_user(session, nil, 0) username = with_string_buffer(username_length) do |username_buffer, size| sp_session_remembered_user(session, username_buffer, size) end username unless username.empty? end |
#session_set_cache_size(session, cache_size) ⇒ Symbol
Set the allowed disk cache size used by libspotify.
152 |
# File 'lib/spotify/api/session.rb', line 152 attach_function :session_set_cache_size, [ Session, :size_t ], APIError |
#session_set_connection_rules(session, rules) ⇒ Symbol
Set rules for how libspotify connects to Spotify servers and synchronizes offline content.
265 |
# File 'lib/spotify/api/session.rb', line 265 attach_function :session_set_connection_rules, [ Session, :connection_rules ], APIError |
#session_set_connection_type(session, type) ⇒ Symbol
Set current connection type.
251 |
# File 'lib/spotify/api/session.rb', line 251 attach_function :session_set_connection_type, [ Session, :connection_type ], APIError |
#session_set_private_session(session, enabled) ⇒ Symbol
Set if private session is enabled.
This disables sharing of what the user is listening to with Spotify Social, Facebook, and LastFM. The private session will automatically revert back to normal state after a period of inactivity (6 hours?).
345 |
# File 'lib/spotify/api/session.rb', line 345 attach_function :session_set_private_session, [ Session, :bool ], APIError |
#session_set_scrobbling(session, social_provider, scrobbling_state) ⇒ Symbol
changing the global settings are currently not supported.
Set if scrobbling should be enabled.
361 |
# File 'lib/spotify/api/session.rb', line 361 attach_function :session_set_scrobbling, [ Session, :social_provider, :scrobbling_state ], APIError |
#session_set_social_credentials(session, social_provider, username, password) ⇒ Symbol
currently this is only relevenat for LastFm
set scrobbling state to true to force an authentication attempt, if it fails the scrobble_error callback will be invoked
Set the user’s credentials for a social provider.
408 |
# File 'lib/spotify/api/session.rb', line 408 attach_function :session_set_social_credentials, [ Session, :social_provider, UTF8String, UTF8String ], APIError |
#session_set_volume_normalization(session, normalize) ⇒ Symbol
Set volume normalization.
314 |
# File 'lib/spotify/api/session.rb', line 314 attach_function :session_set_volume_normalization, [ Session, :bool ], APIError |
#session_starred_create(session) ⇒ Playlist?
if not logged in, the function always return nil.
Returns starred playlist for currently logged in user.
220 |
# File 'lib/spotify/api/session.rb', line 220 attach_function :session_starred_create, [ Session ], Playlist |
#session_starred_for_user_create(session, username) ⇒ Playlist?
if not logged in, the function always return nil.
Returns starred playlist for the specified user.
227 |
# File 'lib/spotify/api/session.rb', line 227 attach_function :session_starred_for_user_create, [ Session, UTF8String ], Playlist |
#session_user(session) ⇒ User?
Returns currently logged in user.
125 |
# File 'lib/spotify/api/session.rb', line 125 attach_function :session_user, [ Session ], User |
#session_user_country(session) ⇒ String
if not logged in, the function always return “ZZ”.
Returns currently logged in user’s country code.
297 |
# File 'lib/spotify/api/session.rb', line 297 attach_function :session_user_country, [ Session ], CountryCode |
#session_user_name(session) ⇒ String
if not logged in, the function always return an empty string.
Returns canonical name for currently logged in user.
334 |
# File 'lib/spotify/api/session.rb', line 334 attach_function :session_user_name, [ Session ], UTF8String |
#session_userdata(session) ⇒ FFI::Pointer
Returns userdata from config in #session_create.
144 |
# File 'lib/spotify/api/session.rb', line 144 attach_function :session_userdata, [ Session ], :userdata |
#toplistbrowse_album(toplist_browse, index) ⇒ Album?
if index is out of range, the function always return nil.
Returns album at index.
63 |
# File 'lib/spotify/api/toplist_browse.rb', line 63 attach_function :toplistbrowse_album, [ ToplistBrowse, :int ], Album |
#toplistbrowse_artist(toplist_browse, : int) ⇒ Artist?
if index is out of range, the function always return nil.
Returns artist at index.
48 |
# File 'lib/spotify/api/toplist_browse.rb', line 48 attach_function :toplistbrowse_artist, [ ToplistBrowse, :int ], Artist |
#toplistbrowse_backend_request_duration(toplist_browse) ⇒ Integer
Returns the time in ms that was spent waiting for Spotify backend to serve request, or -1 if served from cache.
83 |
# File 'lib/spotify/api/toplist_browse.rb', line 83 attach_function :toplistbrowse_backend_request_duration, [ ToplistBrowse ], :int |
#toplistbrowse_create(session, type, region, username, callback, userdata) ⇒ Object
it is very important that the callback is not garbage collected before it is called!
Initiate a request for browsing a toplist.
23 |
# File 'lib/spotify/api/toplist_browse.rb', line 23 attach_function :toplistbrowse_create, [ Session, :toplisttype, :toplistregion, UTF8String, :toplistbrowse_complete_cb, :userdata ], ToplistBrowse |
#toplistbrowse_error(toplist_browse) ⇒ Symbol
Returns error code.
33 |
# File 'lib/spotify/api/toplist_browse.rb', line 33 attach_function :toplistbrowse_error, [ ToplistBrowse ], APIError |
#toplistbrowse_is_loaded(toplist_browse) ⇒ Boolean
Returns true if toplist request has finished loading.
28 |
# File 'lib/spotify/api/toplist_browse.rb', line 28 attach_function :toplistbrowse_is_loaded, [ ToplistBrowse ], :bool |
#toplistbrowse_num_albums(toplist_browse) ⇒ Integer
if the toplist is not loaded, the function always return 0.
Returns number of albums in the toplist result.
55 |
# File 'lib/spotify/api/toplist_browse.rb', line 55 attach_function :toplistbrowse_num_albums, [ ToplistBrowse ], :int |
#toplistbrowse_num_artists(toplist_browse) ⇒ Integer
if the toplist is not loaded, the function always return 0.
Returns number of artists in the toplist result.
40 |
# File 'lib/spotify/api/toplist_browse.rb', line 40 attach_function :toplistbrowse_num_artists, [ ToplistBrowse ], :int |
#toplistbrowse_num_tracks(toplist_browse) ⇒ Integer
if the toplist is not loaded, the function always return 0.
Returns number of tracks in the toplist result.
70 |
# File 'lib/spotify/api/toplist_browse.rb', line 70 attach_function :toplistbrowse_num_tracks, [ ToplistBrowse ], :int |
#toplistbrowse_track(toplist_browse, index) ⇒ Track?
if index is out of range, the function always return nil.
Returns track at index.
78 |
# File 'lib/spotify/api/toplist_browse.rb', line 78 attach_function :toplistbrowse_track, [ ToplistBrowse, :int ], Track |
#track_album(track) ⇒ Album?
if the track is not loaded, the function always return nil.
Returns album of the track.
81 |
# File 'lib/spotify/api/track.rb', line 81 attach_function :track_album, [ Track ], Album |
#track_artist(track, index) ⇒ Artist?
if index is out of range, the function always return nil.
Returns artist at index.
75 |
# File 'lib/spotify/api/track.rb', line 75 attach_function :track_artist, [ Track, :int ], Artist |
#track_disc(track) ⇒ Integer
The function only returns valid data for tracks appearing in an ArtistBrowse or AlbumBrowse result.
if the disc is not available, the function always return 0.
Returns disc number for the track, 1..(total number of discs on album).
106 |
# File 'lib/spotify/api/track.rb', line 106 attach_function :track_disc, [ Track ], :int |
#track_duration(track) ⇒ Integer
if the track is not loaded, the function always return 0.
Returns duration of the track in milliseconds.
93 |
# File 'lib/spotify/api/track.rb', line 93 attach_function :track_duration, [ Track ], :int |
#track_error(track) ⇒ Symbol
Returns error code.
13 |
# File 'lib/spotify/api/track.rb', line 13 attach_function :track_error, [ Track ], APIError |
#track_get_availability(session, track) ⇒ Symbol
if the track is not loaded, the function always return :unavailable.
Returns track availability, one of :unavailable, :available, :not_streamable, :banned_by_artist.
21 |
# File 'lib/spotify/api/track.rb', line 21 attach_function :track_get_availability, [ Session, Track ], :track_availability |
#track_get_playable(session, track) ⇒ Track
If the track has been autolinked, the returned track will not be the same track.
Returns the actual track that will be played if track is scheduled for playback.
132 |
# File 'lib/spotify/api/track.rb', line 132 attach_function :track_get_playable, [ Session, Track ], Track |
#track_index(track) ⇒ Integer
The function only returns valid data for tracks appearing in an ArtistBrowse or AlbumBrowse result.
if the disc is not available, the function always return 0.
Returns position of track on it’s disc, starts at 1.
113 |
# File 'lib/spotify/api/track.rb', line 113 attach_function :track_index, [ Track ], :int |
#track_is_autolinked(session, track) ⇒ Boolean
if the track is not loaded, the function always return false.
Returns true if the track is automatically linked to another playable version of the track.
35 |
# File 'lib/spotify/api/track.rb', line 35 attach_function :track_is_autolinked, [ Session, Track ], :bool |
#track_is_loaded(track) ⇒ Boolean
Returns true if track has finished loading.
8 |
# File 'lib/spotify/api/track.rb', line 8 attach_function :track_is_loaded, [ Track ], :bool |
#track_is_local(session, track) ⇒ Boolean
if the track is not loaded, the function always return false.
Returns true if the track is a local track.
28 |
# File 'lib/spotify/api/track.rb', line 28 attach_function :track_is_local, [ Session, Track ], :bool |
#track_is_placeholder(track) ⇒ Boolean
the track does not need to be loaded for this function to return a correct value.
use #link_create_from_track to get a link to the wrapped item.
Placeholder tracks are a way to store non-track items in a playlist.
This is used when sending playlists to users, for example.
125 |
# File 'lib/spotify/api/track.rb', line 125 attach_function :track_is_placeholder, [ Track ], :bool |
#track_is_starred(session, track) ⇒ Boolean
if the track is not loaded, the function always return false.
Returns true if the track is starred by the current user.
42 |
# File 'lib/spotify/api/track.rb', line 42 attach_function :track_is_starred, [ Session, Track ], :bool |
#track_name(track) ⇒ String
if the track is not loaded, the function always return an empty string.
Returns track name.
87 |
# File 'lib/spotify/api/track.rb', line 87 attach_function :track_name, [ Track ], UTF8String |
#track_num_artists(track) ⇒ Integer
if the track is not loaded, the function always return 0.
Returns number of artists performing the track.
67 |
# File 'lib/spotify/api/track.rb', line 67 attach_function :track_num_artists, [ Track ], :int |
#track_offline_get_status(track) ⇒ Symbol
Returns offline status of track, one of :no, :waiting, :downloading, :done, :error, :done_expired, :limit_exceeded, :done_resync.
137 |
# File 'lib/spotify/api/track.rb', line 137 attach_function :track_offline_get_status, [ Track ], :track_offline_status |
#track_popularity(track) ⇒ Integer
if the track is not loaded, the function always return 0.
Returns popularity of the track, 0..100.
99 |
# File 'lib/spotify/api/track.rb', line 99 attach_function :track_popularity, [ Track ], :int |
#track_set_starred(session, tracks, starred) ⇒ Symbol
Star or unstar a list of tracks.
54 55 56 57 58 59 60 61 |
# File 'lib/spotify/api/track.rb', line 54 attach_function :track_set_starred, [ Session, :array, :int, :bool ], APIError do |session, tracks, starred| tracks = Array(tracks) with_buffer(Spotify::Track, size: tracks.length) do |tracks_buffer| tracks_buffer.write_array_of_pointer(tracks) sp_track_set_starred(session, tracks_buffer, tracks.length, starred) end end |
#user_canonical_name(user) ⇒ String
Returns canonical username of user, the one used by Spotify in just about all places.
8 |
# File 'lib/spotify/api/user.rb', line 8 attach_function :user_canonical_name, [ User ], UTF8String |
#user_display_name(user) ⇒ String
#user_is_loaded can return true even if libspotify does not know the display name yet.
if libspotify does not have a display name, the function will return the canonical name of the user.
Returns display name of user.
15 |
# File 'lib/spotify/api/user.rb', line 15 attach_function :user_display_name, [ User ], UTF8String |
#user_is_loaded(user) ⇒ Boolean
the function may return true, even if display name is not yet known, make sure to #session_process_events!
Returns true if user has finished loading.
21 |
# File 'lib/spotify/api/user.rb', line 21 attach_function :user_is_loaded, [ User ], :bool |