Esempio n. 1
0
		static void HandleOnEndOfTrack(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("End of music delivery. Flushing player buffer...");
			Thread.Sleep(510); // Samples left in player buffer. Player lags 500 ms
			player.Stop();
			player = null;
			Console.WriteLine("Playback complete");
			playbackDone.Set();
		}
Esempio n. 2
0
		static void HandleOnMusicDelivery(Session sender, MusicDeliveryEventArgs e)
		{
			if(e.Samples.Length > 0)
			{
				if(player == null)
				{
                    if (IsWindows())
                    {
                        // Use BASS on Windows.                        
                        player = new BASSPlayer();
                        Console.WriteLine("BASSPlayer created");
                    }
                    else
                    {
                        player = new AlsaPlayer(e.Rate / 2); // Buffer 500ms of audio
                        Console.WriteLine("AlsaPlayer created with buffer size {0} frames", e.Rate / 2);
                    }
				}
				
				// Don't forget to set how many frames we consumed
				e.ConsumedFrames = player.EnqueueSamples(e.Channels, e.Rate, e.Samples, e.Frames);
			}
			else
			{
				e.ConsumedFrames = 0;
			}
		}