Beispiel #1
0
        public async Task Player_ChangeRepeatMode()
        {
            var previous = await Player.GetRepeatMode();

            try
            {
                await Player.SetRepeatMode(RepeatMode.RepeatOff);

                var completion = new TaskCompletionSource <RepeatMode>();

                using (Player.RepeatModeChanges
                       .Where(element => element == RepeatMode.RepeatAll)
                       .Timeout(TimeSpan.FromSeconds(2))
                       .Subscribe(value =>
                {
                    completion.SetResult(value);
                }))
                {
                    await Player.SetRepeatMode(RepeatMode.RepeatAll);

                    await completion.Task;
                };
            }
            finally
            {
                await Player.SetRepeatMode(previous);
            }
        }
Beispiel #2
0
        private static async Task DumpPlayer(BluPlayer player)
        {
            Console.WriteLine($"State: {await player.GetState()}");
            Console.WriteLine($"Shuffle: {await player.GetShuffleMode()}");
            Console.WriteLine($"Repeat: {await player.GetRepeatMode()}");
            Console.WriteLine($"Volume: {await player.GetVolume()}%");
            Console.WriteLine($"Position: {await player.GetPosition()}");

            DumpPresets(await player.PresetList.GetPresets());
            DumpMedia(await player.GetMedia());
            DumpQueueInfo(await player.PlayQueue.GetInfo());
            await DumpMusicBrowser(player.MusicBrowser);

            Console.WriteLine(new string('=', 80));
            Console.WriteLine();

            Console.WriteLine("Waiting for changes...");
            WriteInstructions();

            player.StateChanges.Subscribe(state =>
            {
                Console.WriteLine($"State: {state}");
            });

            player.ShuffleModeChanges.Subscribe(mode =>
            {
                Console.WriteLine($"Shuffle: {mode}");
            });

            player.RepeatModeChanges.Subscribe(mode =>
            {
                Console.WriteLine($"Repeat: {mode}");
            });

            player.VolumeChanges.Subscribe(volume =>
            {
                Console.WriteLine($"Volume: {volume}%");
            });

            player.PositionChanges.Subscribe(position =>
            {
                Console.WriteLine($"Position: {position}");
            });

            player.MediaChanges.Subscribe(media =>
            {
                DumpMedia(media);
            });

            player.PresetList.Changes.Subscribe(presets =>
            {
                DumpPresets(presets);
            });

            player.PlayQueue.Changes.Subscribe(info =>
            {
                DumpQueueInfo(info);
            });
        }