Пример #1
0
 private void OnMusicDataAvailable(Object sender, MusicDeliveryEventArgs args)
 {
     if (MusicDataAvailable != null)
     {
         MusicDataAvailable(sender, args);
     }
 }
Пример #2
0
        private void SpotifyWrapper_MusicDataAvailable(object sender, MusicDeliveryEventArgs e)
        {
            if (e.NumFrames > 0 && _currentState == SpotifyState.Playing)
            {
                if (_numberOfIterations == StartPlaying)
                {
                    StartStream(_streamKey);
                }
                else if (_provider == null)
                {
                    _streamKey = InitializeStream(e.SampleRate, e.NumberOfChannels, e.NumberOfBits, out _provider);
                }

                if (_numberOfIterations <= StartPlaying)
                {
                    _numberOfIterations++;
                }

                var    size         = e.NumFrames * e.NumberOfChannels * (e.NumberOfBits / 8);
                byte[] copiedFrames = new byte[size];
                Marshal.Copy(e.Frames, copiedFrames, 0, size); //Copy Pointer Bytes to _copiedFrames
                _provider.AddData(copiedFrames, 0, size);      //adding bytes from _copiedFrames as samples
                e.NumFramesRead = e.NumFrames;
            }
        }
Пример #3
0
 public override int MusicDelivery(SpotifySession session, AudioFormat format, IntPtr frames, int num_frames)
 {
     if (MusicDataAvailable != null)
     {
         MusicDeliveryEventArgs args = new MusicDeliveryEventArgs(frames, num_frames, format.sample_rate, format.channels, 16);
         MusicDataAvailable(this, args);
         return(args.NumFramesRead);
     }
     return(0);
 }