protected virtual void OnMusicDelivery(MusicDeliveryEventArgs args) { if (this.MusicDeliver != null) { this.MusicDeliver(this, args); } }
private static int MusicDeliveryCallback(IntPtr sessionPtr, IntPtr formatPtr, IntPtr framesPtr, int num_frames) { Session s = GetSession(sessionPtr); if (s == null) { return(0); } byte[] samplesBytes = null; libspotify.sp_audioformat format = (libspotify.sp_audioformat)Marshal.PtrToStructure(formatPtr, typeof(libspotify.sp_audioformat)); if (num_frames > 0) { samplesBytes = new byte[num_frames * format.channels * 2]; Marshal.Copy(framesPtr, samplesBytes, 0, samplesBytes.Length); } else { samplesBytes = new byte[0]; } MusicDeliveryEventArgs e = new MusicDeliveryEventArgs(format.channels, format.sample_rate, samplesBytes, num_frames); s.OnMusicDelivery(e); return(e.ConsumedFrames); }
void session_MusicDelivered(ISession sender, MusicDeliveryEventArgs e) { e.ConsumedFrames = e.Samples.Length > 0 ? player.EnqueueSamples(e.Channels, e.Rate, e.Samples, e.Frames) : 0; }
void spotify_MusicDeliver(ISession sender, MusicDeliveryEventArgs e) { if (e.Samples.Length > 0) { e.ConsumedFrames = player.EnqueueSamples(e.Channels, e.Rate, e.Samples, e.Frames); } else { e.ConsumedFrames = 0; } }