spotify 12.0.0 → 12.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,18 @@
1
+ __v12.1.0__
2
+ -----------
3
+ - erroneously released (wrong version number, does not follow version policy)
4
+
5
+ [v12.0.1][]
6
+ -----------
7
+ - add Spotify::Pointer, a FFI::Pointer that manages spotify pointer refcount!
8
+ - wrap object-creating methods that returns Spotify::Pointers, e.g. albumbrowse_create!
9
+ - add error-checking variants of all functions that return an error e. g. session_relogin!
10
+ - add Spotify::Error with it’s .explain and .disambiguate
11
+
12
+ [v12.0.0][]
13
+ -----------
14
+ - upgrade to libspotify v12.1.45
15
+
1
16
  [v11.0.2][]
2
17
  -----------
3
18
  - make the error message on missing functions more friendly
@@ -103,6 +118,8 @@ v0.0.0
103
118
  ------
104
119
  - release to register rubygems.org name
105
120
 
121
+ [v12.0.1]: https://github.com/Burgestrand/libspotify-ruby/compare/v12.0.0...v12.0.1
122
+ [v12.0.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v11.0.2...v12.0.0
106
123
  [v11.0.2]: https://github.com/Burgestrand/libspotify-ruby/compare/v11.0.1...v11.0.2
107
124
  [v11.0.1]: https://github.com/Burgestrand/libspotify-ruby/compare/v11.0.0...v11.0.1
108
125
  [v11.0.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.3.0...v11.0.0
@@ -28,7 +28,7 @@ A note about versioning scheme
28
28
  ------------------------------
29
29
  Given a version `X.Y.Z`, each segment corresponds to:
30
30
 
31
- - X reflects supported libspotify version (0.0.7 => 7)
31
+ - X reflects supported libspotify version (12.1.45 => 12)
32
32
  - Y is increased **only** on non-backwards-compatible bug fixes or feature additions
33
33
  - Z is increased on backwards-compatible bug fixes or feature additions
34
34
 
@@ -1,766 +1,11 @@
1
1
  # coding: utf-8
2
- require 'ffi'
3
2
  require 'spotify/version'
3
+ require 'ffi'
4
4
 
5
- # FFI wrapper around libspotify.
6
- #
7
- # See official documentation for more detailed documentation about
8
- # functions and their behavior.
9
- #
10
- # @see http://developer.spotify.com/en/libspotify/docs/
11
- module Spotify
12
- extend FFI::Library
13
-
14
- begin
15
- ffi_lib ['libspotify', '/Library/Frameworks/libspotify.framework/libspotify']
16
- rescue LoadError => e
17
- puts "Failed to load the `libspotify` library. Please make sure you have it
18
- installed, either globally on your system, in your LD_LIBRARY_PATH, or in
19
- your current working directory (#{Dir.pwd}).
20
-
21
- For installation instructions, please see:
22
- https://github.com/Burgestrand/Hallon/wiki/How-to-install-libspotify".gsub(/^ */, '')
23
- puts
24
- raise
25
- end
26
-
27
- module UTF8String
28
- extend FFI::DataConverter
29
- native_type FFI::Type::STRING
30
-
31
- if "".respond_to?(:encode)
32
- # convert a Ruby string of any encoding to UTF-8 string
33
- def self.to_native(value, ctx)
34
- if value
35
- value.encode('UTF-8')
36
- else
37
- super
38
- end
39
- end
40
- end
41
-
42
- if "".respond_to?(:force_encoding)
43
- # converts encoding from native BINARY string to UTF-8
44
- def self.from_native(value, ctx)
45
- if value
46
- value.force_encoding('UTF-8')
47
- else
48
- super
49
- end
50
- end
51
- end
52
- end
53
-
54
- module ImageID
55
- extend FFI::DataConverter
56
- native_type FFI::Type::POINTER
57
-
58
- def self.to_native(value, ctx)
59
- pointer = if value
60
- if value.bytesize != 20
61
- raise ArgumentError, "image id bytesize must be 20, was #{value.bytesize}"
62
- end
63
-
64
- pointer = FFI::MemoryPointer.new(:char, 20)
65
- pointer.write_string(value.to_s)
66
- end
67
-
68
- super(pointer, ctx)
69
- end
70
-
71
- def self.from_native(value, ctx)
72
- value.read_string(20) unless value.null?
73
- end
74
- end
75
-
76
- # Override FFI::Library#attach_function to always add the `:blocking` option.
77
- #
78
- # The reason for this is that which libspotify functions may call callbacks
79
- # is unspecified. And really… I don’t know of any drawbacks with this method.
80
- def self.attach_function(*arguments, &block)
81
- options = arguments.pop if arguments.last.is_a?(Hash)
82
- options ||= {}
83
- options = { :blocking => true }.merge(options)
84
- arguments << options
85
- super(*arguments, &block)
86
- end
87
-
88
- # libspotify API version
89
- # @return [Fixnum]
90
- API_VERSION = VERSION.split('.').first.to_i
91
-
92
- # Aliases to Spotify types
93
- typedef :pointer, :frames
94
- typedef :pointer, :session
95
- typedef :pointer, :track
96
- typedef :pointer, :user
97
- typedef :pointer, :playlistcontainer
98
- typedef :pointer, :playlist
99
- typedef :pointer, :link
100
- typedef :pointer, :album
101
- typedef :pointer, :artist
102
- typedef :pointer, :search
103
- typedef :pointer, :image
104
- typedef :pointer, :albumbrowse
105
- typedef :pointer, :artistbrowse
106
- typedef :pointer, :toplistbrowse
107
- typedef :pointer, :inbox
108
-
109
- typedef :pointer, :userdata
110
- typedef :pointer, :array
111
-
112
- typedef :pointer, :string_pointer
113
-
114
- typedef UTF8String, :utf8_string
115
- typedef ImageID, :image_id
116
-
117
- #
118
- # Error
119
- #
120
- # @see http://developer.spotify.com/en/libspotify/docs/group__error.html
121
-
122
- #
123
- enum :error, [:ok, 0,
124
- :bad_api_version, :api_initialization_failed, :track_not_playable,
125
-
126
- :bad_application_key, 5,
127
- :bad_username_or_password, :user_banned,
128
- :unable_to_contact_server, :client_too_old, :other_permanent,
129
- :bad_user_agent, :missing_callback, :invalid_indata,
130
- :index_out_of_range, :user_needs_premium, :other_transient,
131
- :is_loading, :no_stream_available, :permission_denied,
132
- :inbox_is_full, :no_cache, :no_such_user, :no_credentials,
133
- :network_disabled, :invalid_device_id, :cant_open_trace_file,
134
- :application_banned,
135
-
136
- :offline_too_many_tracks, 31,
137
- :offline_disk_cache, :offline_expired, :offline_not_allowed,
138
- :offline_license_lost, :offline_license_error,
139
-
140
- :lastfm_auth_error, 39,
141
- :invalid_argument, :system_failure]
142
-
143
- # @macro [attach] attach_function
144
- #
145
- # Calls +$2+. See source for actual parameters.
146
- #
147
- # @method $1($3)
148
- # @return [$4]
149
- attach_function :error_message, :sp_error_message, [ :error ], :utf8_string
150
-
151
- #
152
- # Miscellaneous
153
- #
154
- # These don’t fit anywhere else :(
155
- attach_function :build_id, :sp_build_id, [], :utf8_string
156
-
157
- #
158
- # Audio
159
- #
160
- # @see http://developer.spotify.com/en/libspotify/docs/group__session.html
161
-
162
- #
163
- enum :sampletype, [:int16] # int16_native_endian
164
- enum :bitrate, %w(160k 320k 96k).map(&:to_sym)
165
-
166
- # FFI::Struct for Audio Format.
167
- #
168
- # @attr [:sampletype] sample_type
169
- # @attr [Fixnum] sample_rate
170
- # @attr [Fixnum] channels
171
- class AudioFormat < FFI::Struct
172
- layout :sample_type, :sampletype,
173
- :sample_rate, :int,
174
- :channels, :int
175
- end
176
-
177
- # FFI::Struct for Audio Buffer Stats.
178
- #
179
- # @attr [Fixnum] samples
180
- # @attr [Fixnum] stutter
181
- class AudioBufferStats < FFI::Struct
182
- layout :samples, :int,
183
- :stutter, :int
184
- end
185
-
186
- #
187
- # Session
188
- #
189
- # @see http://developer.spotify.com/en/libspotify/docs/group__session.html
190
-
191
- # FFI::Struct for Session callbacks.
192
- #
193
- # @attr [callback(:session, :error):void] logged_in
194
- # @attr [callback(:session):void] logged_out
195
- # @attr [callback(:session):void] metadata_updated
196
- # @attr [callback(:session, :error):void] connection_error
197
- # @attr [callback(:session, :utf8_string):void] message_to_user
198
- # @attr [callback(:session):void] notify_main_thread
199
- # @attr [callback(:session, AudioFormat, :frames, :int):int] music_delivery
200
- # @attr [callback(:session):void] play_token_lost
201
- # @attr [callback(:session, :utf8_string):void] log_message
202
- # @attr [callback(:session):void] end_of_track
203
- # @attr [callback(:session, :error):void] streaming_error
204
- # @attr [callback(:session):void] userinfo_updated
205
- # @attr [callback(:session):void] start_playback
206
- # @attr [callback(:session):void] stop_playback
207
- # @attr [callback(:session, AudioBufferStats):void] get_audio_buffer_stats
208
- # @attr [callback(:session)::void] offline_status_updated
209
- class SessionCallbacks < FFI::Struct
210
- layout :logged_in, callback([ :session, :error ], :void),
211
- :logged_out, callback([ :session ], :void),
212
- :metadata_updated, callback([ :session ], :void),
213
- :connection_error, callback([ :session, :error ], :void),
214
- :message_to_user, callback([ :session, :utf8_string ], :void),
215
- :notify_main_thread, callback([ :session ], :void),
216
- :music_delivery, callback([ :session, AudioFormat, :frames, :int ], :int),
217
- :play_token_lost, callback([ :session ], :void),
218
- :log_message, callback([ :session, :utf8_string ], :void),
219
- :end_of_track, callback([ :session ], :void),
220
- :streaming_error, callback([ :session, :error ], :void),
221
- :userinfo_updated, callback([ :session ], :void),
222
- :start_playback, callback([ :session ], :void),
223
- :stop_playback, callback([ :session ], :void),
224
- :get_audio_buffer_stats, callback([ :session, AudioBufferStats ], :void),
225
- :offline_status_updated, callback([ :session ], :void),
226
- :offline_error, callback([ :session, :error ], :void),
227
- :credentials_blob_updated, callback([ :session, :string ], :void),
228
- :connectionstate_updated, callback([ :session ], :void),
229
- :scrobble_error, callback([ :session, :error ], :void),
230
- :private_session_mode_changed, callback([ :session, :bool ], :void)
231
- end
232
-
233
- # FFI::Struct for Session configuration.
234
- #
235
- # @attr [Fixnum] api_version
236
- # @attr [Pointer] cache_location
237
- # @attr [Pointer] settings_location
238
- # @attr [size_t] application_key_size
239
- # @attr [Pointer] user_agent
240
- # @attr [Pointer] callbacks
241
- # @attr [Pointer] userdata
242
- # @attr [Fixnum] dont_save_metadata_for_playlists
243
- # @attr [Fixnum] initially_unload_playlists
244
- class SessionConfig < FFI::Struct
245
- layout :api_version, :int,
246
- :cache_location, :string_pointer,
247
- :settings_location, :string_pointer,
248
- :application_key, :pointer,
249
- :application_key_size, :size_t,
250
- :user_agent, :string_pointer,
251
- :callbacks, SessionCallbacks.by_ref,
252
- :userdata, :userdata,
253
- :compress_playlists, :bool,
254
- :dont_save_metadata_for_playlists, :bool,
255
- :initially_unload_playlists, :bool,
256
- :device_id, :string_pointer,
257
- :proxy, :string_pointer,
258
- :proxy_username, :string_pointer,
259
- :proxy_password, :string_pointer,
260
- :tracefile, :string_pointer
261
- end
262
-
263
- # FFI::Struct for Offline Sync Status
264
- #
265
- # @attr [Fixnum] queued_tracks
266
- # @attr [Fixnum] queued_bytes
267
- # @attr [Fixnum] done_tracks
268
- # @attr [Fixnum] done_bytes
269
- # @attr [Fixnum] copied_tracks
270
- # @attr [Fixnum] copied_bytes
271
- # @attr [Fixnum] willnotcopy_tracks
272
- # @attr [Fixnum] error_tracks
273
- # @attr [Fixnum] syncing
274
- class OfflineSyncStatus < FFI::Struct
275
- layout :queued_tracks, :int,
276
- :queued_bytes, :uint64,
277
- :done_tracks, :int,
278
- :done_bytes, :uint64,
279
- :copied_tracks, :int,
280
- :copied_bytes, :uint64,
281
- :willnotcopy_tracks, :int,
282
- :error_tracks, :int,
283
- :syncing, :bool
284
- end
285
-
286
- #
287
- enum :social_provider, [:spotify, :facebook, :lastfm]
288
-
289
- #
290
- enum :scrobbling_state, [:use_global_setting, :local_enabled, :local_disabled, :global_enabled, :global_disabled]
291
-
292
- #
293
- enum :connectionstate, [:logged_out, :logged_in, :disconnected, :undefined, :offline]
294
-
295
- #
296
- enum :connection_type, [:unknown, :none, :mobile, :mobile_roaming, :wifi, :wired]
297
-
298
- #
299
- enum :connection_rules, [:network , 0x1,
300
- :network_if_roaming , 0x2,
301
- :allow_sync_over_mobile, 0x4,
302
- :allow_sync_over_wifi , 0x8]
303
-
304
- attach_function :session_create, :sp_session_create, [ SessionConfig, :buffer_out ], :error
305
- attach_function :session_release, :sp_session_release, [ :session ], :error
306
-
307
- attach_function :session_process_events, :sp_session_process_events, [ :session, :buffer_out ], :error
308
- attach_function :session_login, :sp_session_login, [ :session, :utf8_string, :string, :bool, :string ], :error
309
- attach_function :session_relogin, :sp_session_relogin, [ :session ], :error
310
- attach_function :session_forget_me, :sp_session_forget_me, [ :session ], :error
311
- attach_function :session_remembered_user, :sp_session_remembered_user, [ :session, :buffer_out, :size_t ], :int
312
-
313
- attach_function :session_user, :sp_session_user, [ :session ], :user
314
- attach_function :session_logout, :sp_session_logout, [ :session ], :error
315
- attach_function :session_connectionstate, :sp_session_connectionstate, [ :session ], :connectionstate
316
- attach_function :session_userdata, :sp_session_userdata, [ :session ], :userdata
317
- attach_function :session_set_cache_size, :sp_session_set_cache_size, [ :session, :size_t ], :error
318
- attach_function :session_player_load, :sp_session_player_load, [ :session, :track ], :error
319
- attach_function :session_player_seek, :sp_session_player_seek, [ :session, :int ], :error
320
- attach_function :session_player_play, :sp_session_player_play, [ :session, :bool ], :error
321
- attach_function :session_player_unload, :sp_session_player_unload, [ :session ], :error
322
- attach_function :session_player_prefetch, :sp_session_player_prefetch, [ :session, :track ], :error
323
- attach_function :session_playlistcontainer, :sp_session_playlistcontainer, [ :session ], :playlistcontainer
324
- attach_function :session_inbox_create, :sp_session_inbox_create, [ :session ], :playlist
325
- attach_function :session_starred_create, :sp_session_starred_create, [ :session ], :playlist
326
- attach_function :session_starred_for_user_create, :sp_session_starred_for_user_create, [ :session, :utf8_string ], :playlist
327
- attach_function :session_publishedcontainer_for_user_create, :sp_session_publishedcontainer_for_user_create, [ :playlist, :utf8_string ], :playlistcontainer
328
- attach_function :session_preferred_bitrate, :sp_session_preferred_bitrate, [ :session, :bitrate ], :error
329
-
330
- attach_function :session_set_connection_type, :sp_session_set_connection_type, [ :session, :connection_type ], :error
331
- attach_function :session_set_connection_rules, :sp_session_set_connection_rules, [ :session, :connection_rules ], :error
332
-
333
- attach_function :offline_tracks_to_sync, :sp_offline_tracks_to_sync, [ :session ], :int
334
- attach_function :offline_num_playlists, :sp_offline_num_playlists, [ :session ], :int
335
- attach_function :offline_sync_get_status, :sp_offline_sync_get_status, [ :session, OfflineSyncStatus ], :bool
336
- attach_function :offline_time_left, :sp_offline_time_left, [ :session ], :int
337
-
338
- attach_function :session_user_country, :sp_session_user_country, [ :session ], :int
339
- attach_function :session_preferred_offline_bitrate, :sp_session_preferred_offline_bitrate, [ :session, :bitrate, :bool ], :error
340
-
341
- attach_function :session_set_volume_normalization, :sp_session_set_volume_normalization, [ :session, :bool ], :error
342
- attach_function :session_get_volume_normalization, :sp_session_get_volume_normalization, [ :session ], :bool
343
-
344
- attach_function :session_flush_caches, :sp_session_flush_caches, [ :session ], :error
345
- attach_function :session_user_name, :sp_session_user_name, [ :session ], :string
346
-
347
- attach_function :session_set_private_session, :sp_session_set_private_session, [ :session, :bool ], :error
348
- attach_function :session_is_private_session, :sp_session_is_private_session, [ :session ], :bool
349
- attach_function :session_set_scrobbling, :sp_session_set_scrobbling, [ :session, :social_provider, :scrobbling_state ], :error
350
- attach_function :session_is_scrobbling, :sp_session_is_scrobbling, [ :session, :social_provider, :buffer_out ], :error
351
- attach_function :session_is_scrobbling_possible, :sp_session_is_scrobbling_possible, [ :session, :social_provider, :buffer_out ], :error
352
- attach_function :session_set_social_credentials, :sp_session_set_social_credentials, [ :session, :social_provider, :utf8_string, :string ], :error
353
-
354
- #
355
- # Images
356
- #
357
- # @see http://developer.spotify.com/en/libspotify/docs/group__image.html
358
-
359
- #
360
- enum :imageformat, [:unknown, -1, :jpeg]
361
- enum :image_size, [ :normal, :small, :large ]
362
-
363
- callback :image_loaded_cb, [ :image, :userdata ], :void
364
- attach_function :image_create, :sp_image_create, [ :session, :image_id ], :image
365
- attach_function :image_add_load_callback, :sp_image_add_load_callback, [ :image, :image_loaded_cb, :userdata ], :error
366
- attach_function :image_remove_load_callback, :sp_image_remove_load_callback, [ :image, :image_loaded_cb, :userdata ], :error
367
- attach_function :image_is_loaded, :sp_image_is_loaded, [ :image ], :bool
368
- attach_function :image_error, :sp_image_error, [ :image ], :error
369
- attach_function :image_format, :sp_image_format, [ :image ], :imageformat
370
- attach_function :image_data, :sp_image_data, [ :image, :buffer_out ], :pointer
371
- attach_function :image_image_id, :sp_image_image_id, [ :image ], :image_id
372
- attach_function :image_create_from_link, :sp_image_create_from_link, [ :session, :link ], :image
373
-
374
- attach_function :image_add_ref, :sp_image_add_ref, [ :image ], :error
375
- attach_function :image_release, :sp_image_release, [ :image ], :error
376
-
377
-
378
- #
379
- # Link
380
- #
381
- # @see http://developer.spotify.com/en/libspotify/docs/group__link.html
382
-
383
- #
384
- enum :linktype, [:invalid, :track, :album, :artist, :search,
385
- :playlist, :profile, :starred, :localtrack, :image]
386
-
387
- attach_function :link_create_from_string, :sp_link_create_from_string, [ :string ], :link
388
- attach_function :link_create_from_track, :sp_link_create_from_track, [ :track, :int ], :link
389
- attach_function :link_create_from_album, :sp_link_create_from_album, [ :album ], :link
390
- attach_function :link_create_from_artist, :sp_link_create_from_artist, [ :artist ], :link
391
- attach_function :link_create_from_search, :sp_link_create_from_search, [ :search ], :link
392
- attach_function :link_create_from_playlist, :sp_link_create_from_playlist, [ :playlist ], :link
393
- attach_function :link_create_from_artist_portrait, :sp_link_create_from_artist_portrait, [ :artist, :image_size ], :link
394
- attach_function :link_create_from_artistbrowse_portrait, :sp_link_create_from_artistbrowse_portrait, [ :artistbrowse, :int ], :link
395
- attach_function :link_create_from_album_cover, :sp_link_create_from_album_cover, [ :album, :image_size ], :link
396
- attach_function :link_create_from_image, :sp_link_create_from_image, [ :image ], :link
397
- attach_function :link_create_from_user, :sp_link_create_from_user, [ :user ], :link
398
- attach_function :link_as_string, :sp_link_as_string, [ :link, :buffer_out, :int ], :int
399
- attach_function :link_type, :sp_link_type, [ :link ], :linktype
400
- attach_function :link_as_track, :sp_link_as_track, [ :link ], :track
401
- attach_function :link_as_track_and_offset, :sp_link_as_track_and_offset, [ :link, :buffer_out ], :track
402
- attach_function :link_as_album, :sp_link_as_album, [ :link ], :album
403
- attach_function :link_as_artist, :sp_link_as_artist, [ :link ], :artist
404
- attach_function :link_as_user, :sp_link_as_user, [ :link ], :user
405
-
406
- attach_function :link_add_ref, :sp_link_add_ref, [ :link ], :error
407
- attach_function :link_release, :sp_link_release, [ :link ], :error
408
-
409
- #
410
- # Tracks
411
- #
412
- # @see http://developer.spotify.com/en/libspotify/docs/group__track.html
413
-
414
- enum :availability, [:unavailable, :available, :not_streamable, :banned_by_artist]
415
- typedef :availability, :track_availability
416
-
417
- enum :track_offline_status, [:no, :waiting, :downloading, :done, :error, :done_expired, :limit_exceeded, :done_resync]
418
-
419
- #
420
- attach_function :track_is_loaded, :sp_track_is_loaded, [ :track ], :bool
421
- attach_function :track_error, :sp_track_error, [ :track ], :error
422
- attach_function :track_get_availability, :sp_track_get_availability, [ :session, :track ], :track_availability
423
- attach_function :track_is_local, :sp_track_is_local, [ :session, :track ], :bool
424
- attach_function :track_is_autolinked, :sp_track_is_autolinked, [ :session, :track ], :bool
425
- attach_function :track_is_starred, :sp_track_is_starred, [ :session, :track ], :bool
426
- attach_function :track_set_starred, :sp_track_set_starred, [ :session, :array, :int, :bool ], :error
427
- attach_function :track_num_artists, :sp_track_num_artists, [ :track ], :int
428
- attach_function :track_artist, :sp_track_artist, [ :track, :int ], :artist
429
- attach_function :track_album, :sp_track_album, [ :track ], :album
430
- attach_function :track_name, :sp_track_name, [ :track ], :utf8_string
431
- attach_function :track_duration, :sp_track_duration, [ :track ], :int
432
- attach_function :track_popularity, :sp_track_popularity, [ :track ], :int
433
- attach_function :track_disc, :sp_track_disc, [ :track ], :int
434
- attach_function :track_index, :sp_track_index, [ :track ], :int
435
- attach_function :track_is_placeholder, :sp_track_is_placeholder, [ :track ], :bool
436
- attach_function :track_get_playable, :sp_track_get_playable, [ :session, :track ], :track
437
-
438
- attach_function :track_offline_get_status, :sp_track_offline_get_status, [ :track ], :track_offline_status
439
-
440
- attach_function :localtrack_create, :sp_localtrack_create, [ :utf8_string, :utf8_string, :utf8_string, :int ], :track
441
-
442
- attach_function :track_add_ref, :sp_track_add_ref, [ :track ], :error
443
- attach_function :track_release, :sp_track_release, [ :track ], :error
444
-
445
- #
446
- # Albums
447
- #
448
- # @see http://developer.spotify.com/en/libspotify/docs/group__album.html
449
-
450
- #
451
- enum :albumtype, [:album, :single, :compilation, :unknown]
452
-
453
- attach_function :album_is_loaded, :sp_album_is_loaded, [ :album ], :bool
454
- attach_function :album_is_available, :sp_album_is_available, [ :album ], :bool
455
- attach_function :album_artist, :sp_album_artist, [ :album ], :artist
456
- attach_function :album_cover, :sp_album_cover, [ :album, :image_size ], :image_id
457
- attach_function :album_name, :sp_album_name, [ :album ], :utf8_string
458
- attach_function :album_year, :sp_album_year, [ :album ], :int
459
- attach_function :album_type, :sp_album_type, [ :album ], :albumtype
460
-
461
- attach_function :album_add_ref, :sp_album_add_ref, [ :album ], :error
462
- attach_function :album_release, :sp_album_release, [ :album ], :error
463
-
464
- #
465
- # Album Browser
466
- #
467
- # @see http://developer.spotify.com/en/libspotify/docs/group__albumbrowse.html
468
-
469
- #
470
- callback :albumbrowse_complete_cb, [:albumbrowse, :userdata], :void
471
- attach_function :albumbrowse_create, :sp_albumbrowse_create, [ :session, :album, :albumbrowse_complete_cb, :userdata ], :albumbrowse
472
- attach_function :albumbrowse_is_loaded, :sp_albumbrowse_is_loaded, [ :albumbrowse ], :bool
473
- attach_function :albumbrowse_error, :sp_albumbrowse_error, [ :albumbrowse ], :error
474
- attach_function :albumbrowse_album, :sp_albumbrowse_album, [ :albumbrowse ], :album
475
- attach_function :albumbrowse_artist, :sp_albumbrowse_artist, [ :albumbrowse ], :artist
476
- attach_function :albumbrowse_num_copyrights, :sp_albumbrowse_num_copyrights, [ :albumbrowse ], :int
477
- attach_function :albumbrowse_copyright, :sp_albumbrowse_copyright, [ :albumbrowse, :int ], :utf8_string
478
- attach_function :albumbrowse_num_tracks, :sp_albumbrowse_num_tracks, [ :albumbrowse ], :int
479
- attach_function :albumbrowse_track, :sp_albumbrowse_track, [ :albumbrowse, :int ], :track
480
- attach_function :albumbrowse_review, :sp_albumbrowse_review, [ :albumbrowse ], :utf8_string
481
- attach_function :albumbrowse_backend_request_duration, :sp_albumbrowse_backend_request_duration, [ :albumbrowse ], :int
482
-
483
- attach_function :albumbrowse_add_ref, :sp_albumbrowse_add_ref, [ :albumbrowse ], :error
484
- attach_function :albumbrowse_release, :sp_albumbrowse_release, [ :albumbrowse ], :error
485
-
486
- #
487
- # Artists
488
- #
489
- # @see http://developer.spotify.com/en/libspotify/docs/group__artist.html
490
-
491
- #
492
- attach_function :artist_name, :sp_artist_name, [ :artist ], :utf8_string
493
- attach_function :artist_is_loaded, :sp_artist_is_loaded, [ :artist ], :bool
494
- attach_function :artist_portrait, :sp_artist_portrait, [ :artist, :image_size ], :image_id
495
-
496
- attach_function :artist_add_ref, :sp_artist_add_ref, [ :artist ], :error
497
- attach_function :artist_release, :sp_artist_release, [ :artist ], :error
498
-
499
- #
500
- # Artist Browsing
501
- #
502
- # @see http://developer.spotify.com/en/libspotify/docs/group__artistbrowse.html
503
-
504
- enum :artistbrowse_type, [:full, :no_tracks, :no_albums]
505
-
506
- #
507
- callback :artistbrowse_complete_cb, [:artistbrowse, :userdata], :void
508
- attach_function :artistbrowse_create, :sp_artistbrowse_create, [ :session, :artist, :artistbrowse_type, :artistbrowse_complete_cb, :userdata ], :artistbrowse
509
- attach_function :artistbrowse_is_loaded, :sp_artistbrowse_is_loaded, [ :artistbrowse ], :bool
510
- attach_function :artistbrowse_error, :sp_artistbrowse_error, [ :artistbrowse ], :error
511
- attach_function :artistbrowse_artist, :sp_artistbrowse_artist, [ :artistbrowse ], :artist
512
- attach_function :artistbrowse_num_portraits, :sp_artistbrowse_num_portraits, [ :artistbrowse ], :int
513
- attach_function :artistbrowse_portrait, :sp_artistbrowse_portrait, [ :artistbrowse, :int ], :image_id
514
- attach_function :artistbrowse_num_tracks, :sp_artistbrowse_num_tracks, [ :artistbrowse ], :int
515
- attach_function :artistbrowse_track, :sp_artistbrowse_track, [ :artistbrowse, :int ], :track
516
- attach_function :artistbrowse_num_albums, :sp_artistbrowse_num_albums, [ :artistbrowse ], :int
517
- attach_function :artistbrowse_album, :sp_artistbrowse_album, [ :artistbrowse, :int ], :album
518
- attach_function :artistbrowse_num_similar_artists, :sp_artistbrowse_num_similar_artists, [ :artistbrowse ], :int
519
- attach_function :artistbrowse_similar_artist, :sp_artistbrowse_similar_artist, [ :artistbrowse, :int ], :artist
520
- attach_function :artistbrowse_biography, :sp_artistbrowse_biography, [ :artistbrowse ], :utf8_string
521
- attach_function :artistbrowse_backend_request_duration, :sp_artistbrowse_backend_request_duration, [ :artistbrowse ], :int
522
- attach_function :artistbrowse_num_tophit_tracks, :sp_artistbrowse_num_tophit_tracks, [ :artistbrowse ], :int
523
- attach_function :artistbrowse_tophit_track, :sp_artistbrowse_tophit_track, [ :artistbrowse, :int ], :track
524
-
525
- attach_function :artistbrowse_add_ref, :sp_artistbrowse_add_ref, [ :artistbrowse ], :error
526
- attach_function :artistbrowse_release, :sp_artistbrowse_release, [ :artistbrowse ], :error
527
-
528
- #
529
- # Searching
530
- #
531
- # @see http://developer.spotify.com/en/libspotify/docs/group__search.html
532
-
533
- enum :search_type, [:standard, :suggest]
534
-
535
- callback :search_complete_cb, [:search, :userdata], :void
536
- attach_function :search_create, :sp_search_create, [ :session, :utf8_string, :int, :int, :int, :int, :int, :int, :int, :int, :search_type, :search_complete_cb, :userdata ], :search
537
- attach_function :search_is_loaded, :sp_search_is_loaded, [ :search ], :bool
538
- attach_function :search_error, :sp_search_error, [ :search ], :error
539
- attach_function :search_query, :sp_search_query, [ :search ], :utf8_string
540
- attach_function :search_did_you_mean, :sp_search_did_you_mean, [ :search ], :utf8_string
541
- attach_function :search_num_tracks, :sp_search_num_tracks, [ :search ], :int
542
- attach_function :search_track, :sp_search_track, [ :search, :int ], :track
543
- attach_function :search_num_albums, :sp_search_num_albums, [ :search ], :int
544
- attach_function :search_album, :sp_search_album, [ :search, :int ], :album
545
- attach_function :search_num_artists, :sp_search_num_artists, [ :search ], :int
546
- attach_function :search_artist, :sp_search_artist, [ :search, :int ], :artist
547
- attach_function :search_num_playlists, :sp_search_num_playlists, [ :search ], :int
548
- attach_function :search_playlist_name, :sp_search_playlist_name, [ :search, :int ], :utf8_string
549
- attach_function :search_playlist_uri, :sp_search_playlist_uri, [ :search, :int ], :utf8_string
550
- attach_function :search_playlist_image_uri, :sp_search_playlist_image_uri, [ :search, :int ], :utf8_string
551
- attach_function :search_total_tracks, :sp_search_total_tracks, [ :search ], :int
552
- attach_function :search_total_albums, :sp_search_total_albums, [ :search ], :int
553
- attach_function :search_total_artists, :sp_search_total_artists, [ :search ], :int
554
- attach_function :search_total_playlists, :sp_search_total_playlists, [ :search ], :int
555
-
556
- attach_function :search_add_ref, :sp_search_add_ref, [ :search ], :error
557
- attach_function :search_release, :sp_search_release, [ :search ], :error
558
-
559
- #
560
- # Playlists
561
- #
562
- # @see http://developer.spotify.com/en/libspotify/docs/group__playlist.html
563
-
564
- # FFI::Struct for Playlist callbacks.
565
- #
566
- # @attr [callback(:playlist, :array, :int, :int, :userdata):void] tracks_added
567
- # @attr [callback(:playlist, :array, :int, :userdata):void] tracks_removed
568
- # @attr [callback(:playlist, :array, :int, :int, :userdata):void] tracks_moved
569
- # @attr [callback(:playlist, :userdata):void] playlist_renamed
570
- # @attr [callback(:playlist, :userdata):void] playlist_state_changed
571
- # @attr [callback(:playlist, :bool, :userdata):void] playlist_update_in_progress
572
- # @attr [callback(:playlist, :userdata):void] playlist_metadata_updated
573
- # @attr [callback(:playlist, :int, :user, :int, :userdata):void] track_created_changed
574
- # @attr [callback(:playlist, :int, :bool, :userdata):void] track_seen_changed
575
- # @attr [callback(:playlist, :utf8_string, :userdata):void] description_changed
576
- # @attr [callback(:playlist, :image_id, :userdata):void] image_changed
577
- # @attr [callback(:playlist, :int, :utf8_string, :userdata):void] track_message_changed
578
- # @attr [callback(:playlist, :userdata):void] subscribers_changed
579
- class PlaylistCallbacks < FFI::Struct
580
- layout :tracks_added, callback([ :playlist, :array, :int, :int, :userdata ], :void),
581
- :tracks_removed, callback([ :playlist, :array, :int, :userdata ], :void),
582
- :tracks_moved, callback([ :playlist, :array, :int, :int, :userdata ], :void),
583
- :playlist_renamed, callback([ :playlist, :userdata ], :void),
584
- :playlist_state_changed, callback([ :playlist, :userdata ], :void),
585
- :playlist_update_in_progress, callback([ :playlist, :bool, :userdata ], :void),
586
- :playlist_metadata_updated, callback([ :playlist, :userdata ], :void),
587
- :track_created_changed, callback([ :playlist, :int, :user, :int, :userdata ], :void),
588
- :track_seen_changed, callback([ :playlist, :int, :bool, :userdata ], :void),
589
- :description_changed, callback([ :playlist, :utf8_string, :userdata ], :void),
590
- :image_changed, callback([ :playlist, :image_id, :userdata ], :void),
591
- :track_message_changed, callback([ :playlist, :int, :utf8_string, :userdata ], :void),
592
- :subscribers_changed, callback([ :playlist, :userdata ], :void)
593
- end
594
-
595
- # FFI::Struct for Subscribers of a Playlist.
596
- #
597
- # @attr [Fixnum] count
598
- # @attr [Array<Pointer<String>>] subscribers
599
- class Subscribers < FFI::Struct
600
- layout :count, :uint,
601
- :subscribers, [:pointer, 1] # array of pointers to strings
602
-
603
- # Redefined, as the layout of the Struct can only be determined
604
- # at run-time.
605
- #
606
- # @param [FFI::Pointer] pointer
607
- def initialize(pointer)
608
- count = pointer.read_uint
609
-
610
- layout = [:count, :uint]
611
- layout += [:subscribers, [:pointer, count]] if count > 0
612
-
613
- super(pointer, *layout)
614
- end
615
- end
616
-
617
- #
618
- enum :playlist_type, [:playlist, :start_folder, :end_folder, :placeholder]
619
-
620
- #
621
- enum :playlist_offline_status, [:no, :yes, :downloading, :waiting]
622
-
623
- attach_function :playlist_is_loaded, :sp_playlist_is_loaded, [ :playlist ], :bool
624
- attach_function :playlist_add_callbacks, :sp_playlist_add_callbacks, [ :playlist, PlaylistCallbacks, :userdata ], :error
625
- attach_function :playlist_remove_callbacks, :sp_playlist_remove_callbacks, [ :playlist, PlaylistCallbacks, :userdata ], :error
626
- attach_function :playlist_num_tracks, :sp_playlist_num_tracks, [ :playlist ], :int
627
- attach_function :playlist_track, :sp_playlist_track, [ :playlist, :int ], :track
628
- attach_function :playlist_track_create_time, :sp_playlist_track_create_time, [ :playlist, :int ], :int
629
- attach_function :playlist_track_creator, :sp_playlist_track_creator, [ :playlist, :int ], :user
630
- attach_function :playlist_track_seen, :sp_playlist_track_seen, [ :playlist, :int ], :bool
631
- attach_function :playlist_track_set_seen, :sp_playlist_track_set_seen, [ :playlist, :int, :bool ], :error
632
- attach_function :playlist_track_message, :sp_playlist_track_message, [ :playlist, :int ], :utf8_string
633
- attach_function :playlist_name, :sp_playlist_name, [ :playlist ], :utf8_string
634
- attach_function :playlist_rename, :sp_playlist_rename, [ :playlist, :utf8_string ], :error
635
- attach_function :playlist_owner, :sp_playlist_owner, [ :playlist ], :user
636
- attach_function :playlist_is_collaborative, :sp_playlist_is_collaborative, [ :playlist ], :bool
637
- attach_function :playlist_set_collaborative, :sp_playlist_set_collaborative, [ :playlist, :bool ], :error
638
- attach_function :playlist_set_autolink_tracks, :sp_playlist_set_autolink_tracks, [ :playlist, :bool ], :error
639
- attach_function :playlist_get_description, :sp_playlist_get_description, [ :playlist ], :utf8_string
640
- attach_function :playlist_get_image, :sp_playlist_get_image, [ :playlist, :buffer_out ], :bool
641
- attach_function :playlist_has_pending_changes, :sp_playlist_has_pending_changes, [ :playlist ], :bool
642
- attach_function :playlist_add_tracks, :sp_playlist_add_tracks, [ :playlist, :array, :int, :int, :session ], :error
643
- attach_function :playlist_remove_tracks, :sp_playlist_remove_tracks, [ :playlist, :array, :int ], :error
644
- attach_function :playlist_reorder_tracks, :sp_playlist_reorder_tracks, [ :playlist, :array, :int, :int ], :error
645
- attach_function :playlist_num_subscribers, :sp_playlist_num_subscribers, [ :playlist ], :uint
646
- attach_function :playlist_subscribers, :sp_playlist_subscribers, [ :playlist ], Subscribers
647
- attach_function :playlist_subscribers_free, :sp_playlist_subscribers_free, [ Subscribers ], :error
648
- attach_function :playlist_update_subscribers, :sp_playlist_update_subscribers, [ :session, :playlist ], :error
649
- attach_function :playlist_is_in_ram, :sp_playlist_is_in_ram, [ :session, :playlist ], :bool
650
- attach_function :playlist_set_in_ram, :sp_playlist_set_in_ram, [ :session, :playlist, :bool ], :error
651
- attach_function :playlist_create, :sp_playlist_create, [ :session, :link ], :playlist
652
- attach_function :playlist_get_offline_status, :sp_playlist_get_offline_status, [ :session, :playlist ], :playlist_offline_status
653
- attach_function :playlist_get_offline_download_completed, :sp_playlist_get_offline_download_completed, [ :session, :playlist ], :int
654
- attach_function :playlist_set_offline_mode, :sp_playlist_set_offline_mode, [ :session, :playlist, :bool ], :error
655
-
656
- attach_function :playlist_add_ref, :sp_playlist_add_ref, [ :playlist ], :error
657
- attach_function :playlist_release, :sp_playlist_release, [ :playlist ], :error
658
-
659
- #
660
- # Playlist Container
661
- #
662
-
663
- # FFI::Struct for the PlaylistContainer.
664
- #
665
- # @attr [callback(:playlistcontainer, :playlist, :int, :userdata):void] playlist_added
666
- # @attr [callback(:playlistcontainer, :playlist, :int, :userdata):void] playlist_removed
667
- # @attr [callback(:playlistcontainer, :playlist, :int, :int, :userdata):void] playlist_moved
668
- # @attr [callback(:playlistcontainer, :userdata):void] container_loaded
669
- class PlaylistContainerCallbacks < FFI::Struct
670
- layout :playlist_added, callback([ :playlistcontainer, :playlist, :int, :userdata ], :void),
671
- :playlist_removed, callback([ :playlistcontainer, :playlist, :int, :userdata ], :void),
672
- :playlist_moved, callback([ :playlistcontainer, :playlist, :int, :int, :userdata ], :void),
673
- :container_loaded, callback([ :playlistcontainer, :userdata ], :void)
674
- end
675
-
676
- #
677
- attach_function :playlistcontainer_add_callbacks, :sp_playlistcontainer_add_callbacks, [ :playlistcontainer, PlaylistContainerCallbacks, :userdata ], :error
678
- attach_function :playlistcontainer_remove_callbacks, :sp_playlistcontainer_remove_callbacks, [ :playlistcontainer, PlaylistContainerCallbacks, :userdata ], :error
679
- attach_function :playlistcontainer_num_playlists, :sp_playlistcontainer_num_playlists, [ :playlistcontainer ], :int
680
- attach_function :playlistcontainer_playlist, :sp_playlistcontainer_playlist, [ :playlistcontainer, :int ], :playlist
681
- attach_function :playlistcontainer_playlist_type, :sp_playlistcontainer_playlist_type, [ :playlistcontainer, :int ], :playlist_type
682
- attach_function :playlistcontainer_playlist_folder_name, :sp_playlistcontainer_playlist_folder_name, [ :playlistcontainer, :int, :buffer_out, :int ], :error
683
- attach_function :playlistcontainer_playlist_folder_id, :sp_playlistcontainer_playlist_folder_id, [ :playlistcontainer, :int ], :uint64
684
- attach_function :playlistcontainer_add_new_playlist, :sp_playlistcontainer_add_new_playlist, [ :playlistcontainer, :utf8_string ], :playlist
685
- attach_function :playlistcontainer_add_playlist, :sp_playlistcontainer_add_playlist, [ :playlistcontainer, :link ], :playlist
686
- attach_function :playlistcontainer_remove_playlist, :sp_playlistcontainer_remove_playlist, [ :playlistcontainer, :int ], :error
687
- attach_function :playlistcontainer_move_playlist, :sp_playlistcontainer_move_playlist, [ :playlistcontainer, :int, :int, :bool ], :error
688
- attach_function :playlistcontainer_add_folder, :sp_playlistcontainer_add_folder, [ :playlistcontainer, :int, :utf8_string ], :error
689
- attach_function :playlistcontainer_owner, :sp_playlistcontainer_owner, [ :playlistcontainer ], :user
690
- attach_function :playlistcontainer_is_loaded, :sp_playlistcontainer_is_loaded, [ :playlistcontainer ], :bool
691
-
692
- attach_function :playlistcontainer_get_unseen_tracks, :sp_playlistcontainer_get_unseen_tracks, [ :playlistcontainer, :playlist, :array, :int ], :int
693
- attach_function :playlistcontainer_clear_unseen_tracks, :sp_playlistcontainer_clear_unseen_tracks, [ :playlistcontainer, :playlist ], :int
694
-
695
- attach_function :playlistcontainer_add_ref, :sp_playlistcontainer_add_ref, [ :playlistcontainer ], :error
696
- attach_function :playlistcontainer_release, :sp_playlistcontainer_release, [ :playlistcontainer ], :error
697
-
698
- #
699
- # User handling
700
- #
701
- # @see http://developer.spotify.com/en/libspotify/docs/group__user.html
702
-
703
- #
704
- enum :relation_type, [:unknown, :none, :unidirectional, :bidirectional]
705
-
706
- attach_function :user_canonical_name, :sp_user_canonical_name, [ :user ], :utf8_string
707
- attach_function :user_display_name, :sp_user_display_name, [ :user ], :utf8_string
708
- attach_function :user_is_loaded, :sp_user_is_loaded, [ :user ], :bool
709
-
710
- attach_function :user_add_ref, :sp_user_add_ref, [ :user ], :error
711
- attach_function :user_release, :sp_user_release, [ :user ], :error
712
-
713
- #
714
- # Toplists
715
- #
716
- # @see http://developer.spotify.com/en/libspotify/docs/group__toplist.html
717
-
718
- #
719
- enum :toplisttype, [:artists, :albums, :tracks]
720
- enum :toplistregion, [:everywhere, :user]
721
-
722
- callback :toplistbrowse_complete_cb, [:toplistbrowse, :userdata], :void
723
- attach_function :toplistbrowse_create, :sp_toplistbrowse_create, [ :session, :toplisttype, :toplistregion, :utf8_string, :toplistbrowse_complete_cb, :userdata ], :toplistbrowse
724
- attach_function :toplistbrowse_is_loaded, :sp_toplistbrowse_is_loaded, [ :toplistbrowse ], :bool
725
- attach_function :toplistbrowse_error, :sp_toplistbrowse_error, [ :toplistbrowse ], :error
726
- attach_function :toplistbrowse_num_artists, :sp_toplistbrowse_num_artists, [ :toplistbrowse ], :int
727
- attach_function :toplistbrowse_artist, :sp_toplistbrowse_artist, [ :toplistbrowse, :int ], :artist
728
- attach_function :toplistbrowse_num_albums, :sp_toplistbrowse_num_albums, [ :toplistbrowse ], :int
729
- attach_function :toplistbrowse_album, :sp_toplistbrowse_album, [ :toplistbrowse, :int ], :album
730
- attach_function :toplistbrowse_num_tracks, :sp_toplistbrowse_num_tracks, [ :toplistbrowse ], :int
731
- attach_function :toplistbrowse_track, :sp_toplistbrowse_track, [ :toplistbrowse, :int ], :track
732
- attach_function :toplistbrowse_backend_request_duration, :sp_toplistbrowse_backend_request_duration, [ :toplistbrowse ], :int
733
-
734
- attach_function :toplistbrowse_add_ref, :sp_toplistbrowse_add_ref, [ :toplistbrowse ], :error
735
- attach_function :toplistbrowse_release, :sp_toplistbrowse_release, [ :toplistbrowse ], :error
736
-
737
- #
738
- # Inbox
739
- #
740
- # @see http://developer.spotify.com/en/libspotify/docs/group__inbox.html
741
-
742
- #
743
- callback :inboxpost_complete_cb, [:inbox, :userdata], :void
744
- attach_function :inbox_post_tracks, :sp_inbox_post_tracks, [ :session, :utf8_string, :array, :int, :utf8_string, :inboxpost_complete_cb, :userdata ], :inbox
745
- attach_function :inbox_error, :sp_inbox_error, [ :inbox ], :error
746
-
747
- attach_function :inbox_add_ref, :sp_inbox_add_ref, [ :inbox ], :error
748
- attach_function :inbox_release, :sp_inbox_release, [ :inbox ], :error
749
-
750
- # Rescue errors thrown when binding to a method that does not exist. Often
751
- # this is because of the user using an old version of libspotify, or a new
752
- # one. Either way it’s incompatible.
753
- rescue FFI::NotFoundError => e
754
- puts "An error was thrown when binding to the libspotify C functions. Please
755
- make sure you are using an up-to-date libspotify version, compatible with
756
- the current version of the Spotify gem.
757
-
758
- Compatible versions of libspotify should be #{API_VERSION}.x.x
759
-
760
- If it still does not work, see the CHANGELOG for information about which
761
- libspotify version the gem was last updated to work with on GitHub:
762
- https://github.com/Burgestrand/libspotify-ruby/blob/master/CHANGELOG.md
763
- ".gsub(/^ +/, "")
5
+ require 'spotify/types/pointer'
6
+ require 'spotify/types/utf8_string'
7
+ require 'spotify/types/image_id'
764
8
 
765
- raise
766
- end
9
+ require 'spotify/functions'
10
+ require 'spotify/gc_wrappers'
11
+ require 'spotify/error_wrappers'