public NativeSessionCallbacks(NativeSession session) { _session = session; _connectionError = ConnectionErrorCallback; _endOfTrack = EndOfTrackCallback; _getAudioBufferStats = GetAudioBufferStatsCallback; _loggedIn = LoggedInCallback; _loggedOut = LoggedOutCallback; _logMessage = LogMessageCallback; _messageToUser = MessageToUserCallback; _metadataUpdated = MetadataUpdatedCallback; _musicDelivery = MusicDeliveryCallback; _notifyMainThread = NotifyMainThreadCallback; _playTokenLost = PlayTokenLostCallback; _startPlayback = StartPlaybackCallback; _stopPlayback = StopPlaybackCallback; _streamingError = StreamingErrorCallback; _userinfoUpdated = UserinfoUpdatedCallback; _offlineStatusUpdated = OfflineStatusUpdatedCallback; _offlineError = OfflineErrorCallback; _credentialsBlobUpdated = CredentialsBlobUpdatedCallback; _connectionStateUpdated = ConnectionStateUpdatedCallback; _scrobbleError = ScrobbleErrorCallback; _privateSessionModeChanged = PrivateSessionModeChangedCallback; _callbacks = new Spotify.SpotifySessionCallbacks(); _callbacks.LoggedIn = Marshal.GetFunctionPointerForDelegate(_loggedIn); _callbacks.LoggedOut = Marshal.GetFunctionPointerForDelegate(_loggedOut); _callbacks.MetadataUpdated = Marshal.GetFunctionPointerForDelegate(_metadataUpdated); _callbacks.ConnectionError = Marshal.GetFunctionPointerForDelegate(_connectionError); _callbacks.MessageToUser = Marshal.GetFunctionPointerForDelegate(_messageToUser); _callbacks.NotifyMainThread = Marshal.GetFunctionPointerForDelegate(_notifyMainThread); _callbacks.MusicDelivery = Marshal.GetFunctionPointerForDelegate(_musicDelivery); _callbacks.PlayTokenLost = Marshal.GetFunctionPointerForDelegate(_playTokenLost); _callbacks.LogMessage = Marshal.GetFunctionPointerForDelegate(_logMessage); _callbacks.EndOfTrack = Marshal.GetFunctionPointerForDelegate(_endOfTrack); _callbacks.StreamingError = Marshal.GetFunctionPointerForDelegate(_streamingError); _callbacks.UserinfoUpdated = Marshal.GetFunctionPointerForDelegate(_userinfoUpdated); _callbacks.StartPlayback = Marshal.GetFunctionPointerForDelegate(_startPlayback); _callbacks.StopPlayback = Marshal.GetFunctionPointerForDelegate(_stopPlayback); _callbacks.GetAudioBufferStats = Marshal.GetFunctionPointerForDelegate(_getAudioBufferStats); _callbacks.OfflineStatusUpdated = Marshal.GetFunctionPointerForDelegate(_offlineStatusUpdated); _callbacks.OfflineError = Marshal.GetFunctionPointerForDelegate(_offlineError); _callbacks.CredentialsBlobUpdated = Marshal.GetFunctionPointerForDelegate(_credentialsBlobUpdated); _callbacks.ConnectionStateUpdated = Marshal.GetFunctionPointerForDelegate(_connectionStateUpdated); _callbacks.ScrobbleError = Marshal.GetFunctionPointerForDelegate(_scrobbleError); _callbacks.PrivateSessionModeChanged = Marshal.GetFunctionPointerForDelegate(_privateSessionModeChanged); _callbacksHandle = Marshal.AllocHGlobal(CallbacksSize); Marshal.StructureToPtr(_callbacks, _callbacksHandle, true); }