示例#1
0
        private void initCallbacks()
        {
            if (this.Pointer == IntPtr.Zero)
            {
                throw new InvalidOperationException("Invalid playlist pointer.");
            }

            this.fn_tracks_added                = new tracks_added_delegate(tracks_added);
            this.fn_tracks_removed              = new tracks_removed_delegate(tracks_removed);
            this.fn_tracks_moved                = new tracks_moved_delegate(tracks_moved);
            this.fn_playlist_renamed            = new playlist_renamed_delegate(playlist_renamed);
            this.fn_playlist_state_changed      = new playlist_state_changed_delegate(state_changed);
            this.fn_playlist_update_in_progress = new playlist_update_in_progress_delegate(playlist_update_in_progress);
            this.fn_playlist_metadata_updated   = new playlist_metadata_updated_delegate(metadata_updated);
            this.fn_track_created_changed       = new track_created_changed_delegate(track_created_changed);
            this.fn_track_seen_changed          = new track_seen_changed_delegate(track_seen_changed);
            this.fn_description_changed         = new description_changed_delegate(description_changed);
            this.fn_image_changed               = new image_changed_delegate(image_changed);
            this.fn_track_message_changed       = new track_message_changed_delegate(track_message_changed);
            this.fn_subscribers_changed         = new subscribers_changed_delegate(subscribers_changed);

            libspotify.sp_playlist_callbacks callbacks = new libspotify.sp_playlist_callbacks();

            callbacks.tracks_added                = Marshal.GetFunctionPointerForDelegate(fn_tracks_added);
            callbacks.tracks_removed              = Marshal.GetFunctionPointerForDelegate(fn_tracks_removed);
            callbacks.tracks_moved                = Marshal.GetFunctionPointerForDelegate(fn_tracks_moved);
            callbacks.playlist_renamed            = Marshal.GetFunctionPointerForDelegate(fn_playlist_renamed);
            callbacks.playlist_state_changed      = Marshal.GetFunctionPointerForDelegate(fn_playlist_state_changed);
            callbacks.playlist_update_in_progress = Marshal.GetFunctionPointerForDelegate(fn_playlist_update_in_progress);
            callbacks.playlist_metadata_updated   = Marshal.GetFunctionPointerForDelegate(fn_playlist_metadata_updated);
            callbacks.track_created_changed       = Marshal.GetFunctionPointerForDelegate(fn_track_created_changed);
            callbacks.track_seen_changed          = Marshal.GetFunctionPointerForDelegate(fn_track_seen_changed);
            callbacks.description_changed         = Marshal.GetFunctionPointerForDelegate(fn_description_changed);
            callbacks.image_changed               = Marshal.GetFunctionPointerForDelegate(fn_image_changed);
            callbacks.track_message_changed       = Marshal.GetFunctionPointerForDelegate(fn_track_message_changed);
            callbacks.subscribers_changed         = Marshal.GetFunctionPointerForDelegate(fn_subscribers_changed);

            _callbacksPtr = Marshal.AllocHGlobal(Marshal.SizeOf(callbacks));
            Marshal.StructureToPtr(callbacks, _callbacksPtr, true);

            libspotify.sp_playlist_add_callbacks(this.Pointer, _callbacksPtr, IntPtr.Zero);
            Logger.WriteDebug("Initialised callbacks for playlist {0}", this.Name);
        }
示例#2
0
        private void initCallbacks()
        {
            if (this.Pointer == IntPtr.Zero)
                throw new InvalidOperationException("Invalid playlist pointer.");

            this.fn_tracks_added = new tracks_added_delegate(tracks_added);
            this.fn_tracks_removed = new tracks_removed_delegate(tracks_removed);
            this.fn_tracks_moved = new tracks_moved_delegate(tracks_moved);
            this.fn_playlist_renamed = new playlist_renamed_delegate(playlist_renamed);
            this.fn_playlist_state_changed = new playlist_state_changed_delegate(state_changed);
            this.fn_playlist_update_in_progress = new playlist_update_in_progress_delegate(playlist_update_in_progress);
            this.fn_playlist_metadata_updated = new playlist_metadata_updated_delegate(metadata_updated);
            this.fn_track_created_changed = new track_created_changed_delegate(track_created_changed);
            this.fn_track_seen_changed = new track_seen_changed_delegate(track_seen_changed);
            this.fn_description_changed = new description_changed_delegate(description_changed);
            this.fn_image_changed = new image_changed_delegate(image_changed);
            this.fn_track_message_changed = new track_message_changed_delegate(track_message_changed);
            this.fn_subscribers_changed = new subscribers_changed_delegate(subscribers_changed);

            libspotify.sp_playlist_callbacks callbacks = new libspotify.sp_playlist_callbacks();

            callbacks.tracks_added = Marshal.GetFunctionPointerForDelegate(fn_tracks_added);
            callbacks.tracks_removed = Marshal.GetFunctionPointerForDelegate(fn_tracks_removed);
            callbacks.tracks_moved = Marshal.GetFunctionPointerForDelegate(fn_tracks_moved);
            callbacks.playlist_renamed = Marshal.GetFunctionPointerForDelegate(fn_playlist_renamed);
            callbacks.playlist_state_changed = Marshal.GetFunctionPointerForDelegate(fn_playlist_state_changed);
            callbacks.playlist_update_in_progress = Marshal.GetFunctionPointerForDelegate(fn_playlist_update_in_progress);
            callbacks.playlist_metadata_updated = Marshal.GetFunctionPointerForDelegate(fn_playlist_metadata_updated);
            callbacks.track_created_changed = Marshal.GetFunctionPointerForDelegate(fn_track_created_changed);
            callbacks.track_seen_changed = Marshal.GetFunctionPointerForDelegate(fn_track_seen_changed);
            callbacks.description_changed = Marshal.GetFunctionPointerForDelegate(fn_description_changed);
            callbacks.image_changed = Marshal.GetFunctionPointerForDelegate(fn_image_changed);
            callbacks.track_message_changed = Marshal.GetFunctionPointerForDelegate(fn_track_message_changed);
            callbacks.subscribers_changed = Marshal.GetFunctionPointerForDelegate(fn_subscribers_changed);

            _callbacksPtr = Marshal.AllocHGlobal(Marshal.SizeOf(callbacks));
            Marshal.StructureToPtr(callbacks, _callbacksPtr, true);

            libspotify.sp_playlist_add_callbacks(this.Pointer, _callbacksPtr, IntPtr.Zero);
        }