Beispiel #1
0
        private static void OnBroadcastCreated(SharkEvent p_SharkEvent)
        {
            CreatingBroadcast = false;

            QueueManager.FetchCollectionSongs();
            QueueManager.ClearHistory();

            // Add two random songs to the collection.
            if (Application.Library.Queue.CurrentQueue.Count < 2)
            {
                var s_ModuleSongs = ModuleManager.OnFetchingNextSongs(2);

                if (s_ModuleSongs != null && s_ModuleSongs.Count > 0)
                {
                    var s_First = s_ModuleSongs.First();
                    Application.Library.Broadcast.PlaySong(s_First.Key, s_First.Value);
                    return;
                }

                var s_Random          = new Random();
                var s_FirstSongIndex  = s_Random.Next(0, QueueManager.CollectionSongs.Count);
                var s_SecondSongIndex = s_Random.Next(0, QueueManager.CollectionSongs.Count);

                var s_FirstSong  = QueueManager.CollectionSongs[s_FirstSongIndex];
                var s_SecondSong = QueueManager.CollectionSongs[s_SecondSongIndex];

                while (s_SecondSong == s_FirstSong)
                {
                    s_SecondSongIndex = s_Random.Next(0, QueueManager.CollectionSongs.Count);
                    s_SecondSong      = QueueManager.CollectionSongs[s_SecondSongIndex];
                }

                var s_QueueIDs = Application.Library.Broadcast.AddSongs(new List <Int64> {
                    s_FirstSong, s_SecondSong
                });

                if (Application.Library.Broadcast.PlayingSongID == 0)
                {
                    Application.Library.Broadcast.PlaySong(s_FirstSong, s_QueueIDs[s_FirstSong]);
                }
            }
            else if (Application.Library.Broadcast.PlayingSongID == 0)
            {
                var s_ModuleSongs = ModuleManager.OnFetchingNextSongs(1);

                if (s_ModuleSongs != null && s_ModuleSongs.Count > 0)
                {
                    var s_First = s_ModuleSongs.First();
                    Application.Library.Broadcast.PlaySong(s_First.Key, s_First.Value);
                    return;
                }

                var s_Random    = new Random();
                var s_SongIndex = s_Random.Next(0, QueueManager.CollectionSongs.Count);
                var s_FirstSong = QueueManager.CollectionSongs[s_SongIndex];

                var s_QueueIDs = Application.Library.Broadcast.AddSongs(new List <Int64> {
                    s_FirstSong
                });

                Application.Library.Broadcast.PlaySong(s_FirstSong, s_QueueIDs[s_FirstSong]);
            }
            else if (Application.Library.Broadcast.PlayingSongID != 0)
            {
                QueueManager.UpdateQueue();
            }

            // Disable mobile compliance if needed.
            if (!SettingsManager.MobileCompliance())
            {
                DisableMobileCompliance();
            }
        }