Beispiel #1
0
        public void FindSong()
        {
            playlist.Add(GetDefaultSong());
            var exists = IsSongInPlaylist(m => m.Artist.Contains("Marron"));

            Assert.IsTrue(exists);
        }
        public void Test()
        {
            var song1 = "song1";
            var song2 = "song2";
            var song3 = "song3";
            var song4 = "song4";

            _songs = new MusicInfo[] {
                    new MusicInfo() { FullPath = song1 },
                    new MusicInfo() { FullPath = song2 },
                    new MusicInfo() { FullPath = song3 },
                    new MusicInfo() { FullPath = song4 }
                };

            var library = new MemoryLibraryRepository();
            library.ClearLibrary();
            library.AddMusicToLibrary(_songs);

            var loopingWatcher = new RandomSongPlaylistWatcher(2);
            _playlist = new Playlist(loopingWatcher);
            _dummyAudio = new DummyAudioInteractor();

            var player = new Player(_playlist, _dummyAudio, library);

            _playlist.Add(_songs[0]);
            _playlist.Add(_songs[1]);

            loopingWatcher.AttachToPlaylist(_playlist, library);

            player.MaxPlayCount = 3;
            player.Play();
        }
Beispiel #3
0
        /// <summary>
        /// Setup playlist
        /// </summary>
        private void SetupPlaylist()
        {
            var songList = new List <Song>
            {
                //new Song { Artist = "Alex Jones", Name = "My lovely", Emotion = Globals.Emotions.Happy, Source = Globals.SampleSong2},
                //new Song { Artist = "Tomas Mick", Name = "To you", Emotion = Globals.Emotions.Sad, Source = Globals.SampleSong3},
                new Song {
                    Artist = "Yu", Name = "ERT", Emotion = Globals.Emotions.Sad, Source = Globals.SampleSong4
                },
                new Song {
                    Artist = "Nicholas", Name = "S1u", Emotion = Globals.Emotions.Angry, Source = Globals.SampleSong5
                },
                new Song {
                    Artist = "Volt", Name = "is it you", Emotion = Globals.Emotions.Sad, Source = Globals.SampleSong6
                },
                //new Song { Artist = "Tomas Mick", Name = "To", Emotion = Globals.Emotions.Happy, Source = Globals.SampleSong7},
                //new Song { Artist =  "Mick", Name = "To you", Emotion = Globals.Emotions.Neutral, Source = Globals.SampleSong8},
            };

            FullPlaylist.Add(songList);

            songList      = FullPlaylist.SongList.Where(p => p.Emotion == Globals.Emotions.Happy).Select(p => p).ToList();
            HappyPlaylist = new Playlist(songList);

            songList        = FullPlaylist.SongList.Where(p => p.Emotion == Globals.Emotions.Neutral).Select(p => p).ToList();
            NeutralPlaylist = new Playlist(songList);

            songList    = FullPlaylist.SongList.Where(p => p.Emotion == Globals.Emotions.Sad).Select(p => p).ToList();
            SadPlaylist = new Playlist(songList);

            playList = FullPlaylist;
        }
Beispiel #4
0
    static void Main()
    {
        var      numberOfSongs = int.Parse(Console.ReadLine());
        Playlist playlist      = new Playlist();

        for (int i = 0; i < numberOfSongs; i++)
        {
            try
            {
                var song = Console
                           .ReadLine()
                           .Split(";", StringSplitOptions.RemoveEmptyEntries);

                SongValidator.Song(song);

                Track track = new Track(song[0], song[1], song[2]);

                Console.WriteLine("Song added.");
                playlist.Add(track);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        Console.WriteLine(playlist);
    }
Beispiel #5
0
        /// <summary>
        /// 主界面右侧
        /// 添加空闲歌单按钮的
        /// dialog 的
        /// 关闭事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void DialogAddPlaylist(object sender, DialogClosingEventArgs eventArgs)
        {
            if (eventArgs.Parameter.Equals(true) && !string.IsNullOrWhiteSpace(AddPlaylistTextBox.Text))
            {
                var             keyword      = AddPlaylistTextBox.Text;
                List <SongInfo> songInfoList = null;

                if (SearchModules.PrimaryModule != SearchModules.NullModule && SearchModules.PrimaryModule.IsPlaylistSupported)
                {
                    songInfoList = SearchModules.PrimaryModule.SafeGetPlaylist(keyword);
                }

                // 歌单只使用主搜索模块搜索

                if (songInfoList == null)
                {
                    return;
                }

                foreach (var item in songInfoList)
                {
                    Playlist.Add(item);
                }
            }
            AddPlaylistTextBox.Text = string.Empty;
        }
        /// <summary>
        /// Adiciona novas músicas à playlist utilizando a API do YouTube para realizar a busca.
        /// </summary>
        /// <param name="numberOfTracksToGrab"> How many songs to search for. </param>
        /// <returns></returns>
        public static async Task AddSongs(short numberOfTracksToGrab)
        {
            LavalinkGuildConnection guildConnection = LavalinkNode.GetGuildConnection(await Lavalink.Client.GetGuildAsync(configJson.ServerId).ConfigureAwait(false));

            for (int i = 0; i < numberOfTracksToGrab; i++)
            {
                WordsGenerator _wordsGenerator = new WordsGenerator(_randomNumber);
                List <string>  wordList        = _wordsGenerator.GenerateWordList();

                YoutubeSearchEngine         _youtubeSearchEngine = new YoutubeSearchEngine(1);
                Dictionary <string, string> searchResult         = _youtubeSearchEngine.SearchVideos(wordList);

                foreach (var result in searchResult)
                {
                    Uri videoUri = new Uri(result.Value);
                    LavalinkLoadResult loadResult = await LavalinkNode.Rest.GetTracksAsync(videoUri).ConfigureAwait(false);

                    if (loadResult.LoadResultType == LavalinkLoadResultType.LoadFailed || loadResult.LoadResultType == LavalinkLoadResultType.NoMatches)
                    {
                        await guildConnection.Guild.GetChannel(configJson.ComandosBotCanalId).SendMessageAsync($"ERR0! Pesquisa por {searchResult} falhou! Tipo do resultado: {result.Key}").ConfigureAwait(false);
                    }
                    else
                    {
                        Playlist.Add(loadResult.Tracks.First());
                        await guildConnection.Guild.GetChannel(configJson.ComandosBotCanalId).SendMessageAsync($"A música: {loadResult.Tracks.First().Title} foi adicionada à playlist de músicas para tocar!").ConfigureAwait(false);
                    }
                }
            }
        }
Beispiel #7
0
 public void AddToPlaylist(DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         Playlist.Add((string[])e.Data.GetData(DataFormats.FileDrop));
     }
 }
Beispiel #8
0
        private async Task Add()
        {
            int i = await CheckForPlaylist();

            if (i != -1)
            {
                Playlist list = Storage.PlayLists[i];
                try
                {
                    int i2 = 0;
                    int.TryParse(msg[3], out i2);
                    if (player.HasSearch())
                    {
                        list.Add(player.source.SearchList[i2 - 1], true);
                        Storage.SavePlayList(Storage.PlayLists[i]);
                        await ctx.RespondAsync("Added song " + DiscordString.Bold(player.source.SearchList[i2 - 1].Title) + " to playlist " + DiscordString.Bold(list.Name) + "\n" + list.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    await ctx.RespondAsync("Could not add song to playlist due to unknow error");
                }
            }
        }
Beispiel #9
0
        public async Task AddOrUpdateBeatmapToPlaylist(Beatmap beatmap)
        {
            if (beatmap.IsTemporary)
            {
                //throw new Exception("The beatmap is temporary which can not be added to playlist.");
                return;
            }

            var map = await Playlist.FirstOrDefaultAsync(k => k.BeatmapId == beatmap.Id);

            if (map == null)
            {
                Playlist.Add(new BeatmapCurrentPlay
                {
                    Id       = Guid.NewGuid(),
                    Beatmap  = beatmap,
                    PlayTime = DateTime.Now
                });
            }
            else
            {
                map.PlayTime = DateTime.Now;
            }

            await SaveChangesAsync();
        }
Beispiel #10
0
        public async Task <bool> InitDataServiceAsClient(string code)
        {
            if (CloudService.Instance.State != ServiceState.Connected)
            {
                return(false);
            }

            var result = await CloudService.Instance.JoinParty(code);

            if (!result.Success)
            {
                return(false);
            }

            foreach (var song in result.Songs)
            {
                Playlist.Add(song);
            }

            foreach (var user in result.Users)
            {
                Users.Add(user);
            }

            PartyCode = code;

            return(true);
        }
Beispiel #11
0
        private void RecordingSuitDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var originalSender = e.OriginalSource as FrameworkElement;

            if (originalSender == null)
            {
                return;
            }

            var row = originalSender.ParentOfType <GridViewRow>();

            if (row == null)
            {
                return;
            }

            var recordingSuit = row.DataContext as RecordingSuit;

            if (recordingSuit != null)
            {
                Playlist.Clear();
                foreach (var recording in recordingSuit.Recordings)
                {
                    Playlist.Add(new Recording(recording.Name, recording.Path));
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// 应用设置
        /// </summary>
        /// <param name="config"></param>
        private void ApplyConfig(Config config)
        {
            Player.PlayerType             = config.PlayerType;
            Player.DirectSoundDevice      = config.DirectSoundDevice;
            Player.WaveoutEventDevice     = config.WaveoutEventDevice;
            Player.Volume                 = config.Volume;
            Player.IsPlaylistEnabled      = config.IsPlaylistEnabled;
            SearchModules.PrimaryModule   = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == config.PrimaryModuleId) ?? SearchModules.NullModule;
            SearchModules.SecondaryModule = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == config.SecondaryModuleId) ?? SearchModules.NullModule;
            DanmuHandler.MaxTotalSongNum  = config.MaxTotalSongNum;
            DanmuHandler.MaxPersonSongNum = config.MaxPersonSongNum;
            Writer.ScribanTemplate        = config.ScribanTemplate;

            Playlist.Clear();
            foreach (var item in config.Playlist)
            {
                item.Module = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == item.ModuleId);
                if (item.Module != null)
                {
                    Playlist.Add(item);
                }
            }

            Blacklist.Clear();
            foreach (var item in config.Blacklist)
            {
                Blacklist.Add(item);
            }
        }
Beispiel #13
0
        /// <summary>
        /// 主界面右侧
        /// 添加空闲歌曲按钮的
        /// dialog 的
        /// 关闭事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void DialogAddSongsToPlaylist(object sender, DialogClosingEventArgs eventArgs)
        {
            if (eventArgs.Parameter.Equals(true) && !string.IsNullOrWhiteSpace(AddSongPlaylistTextBox.Text))
            {
                var      keyword  = AddSongPlaylistTextBox.Text;
                SongInfo songInfo = null;

                if (SearchModules.PrimaryModule != SearchModules.NullModule)
                {
                    songInfo = SearchModules.PrimaryModule.SafeSearch(keyword);
                }

                if (songInfo == null)
                {
                    if (SearchModules.SecondaryModule != SearchModules.NullModule)
                    {
                        songInfo = SearchModules.SecondaryModule.SafeSearch(keyword);
                    }
                }

                if (songInfo == null)
                {
                    return;
                }

                Playlist.Add(songInfo);
            }
            AddSongPlaylistTextBox.Text = string.Empty;
        }
Beispiel #14
0
        protected override void SelectItem(PlaylistItem item)
        {
            // If the client is already in a room, update via the client.
            // Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation.
            if (client.Room != null)
            {
                loadingLayer.Show();

                client.ChangeSettings(item: item).ContinueWith(t =>
                {
                    Schedule(() =>
                    {
                        loadingLayer.Hide();

                        if (t.IsCompletedSuccessfully)
                        {
                            this.Exit();
                        }
                        else
                        {
                            Logger.Log($"Could not use current beatmap ({t.Exception?.Message})", level: LogLevel.Important);
                            Carousel.AllowSelection = true;
                        }
                    });
                });
            }
            else
            {
                Playlist.Clear();
                Playlist.Add(item);
                this.Exit();
            }
        }
Beispiel #15
0
        protected override void SelectItem(PlaylistItem item)
        {
            // If the client is already in a room, update via the client.
            // Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation.
            if (client.Room != null)
            {
                loadingLayer.Show();

                var multiplayerItem = new MultiplayerPlaylistItem
                {
                    ID              = itemToEdit ?? 0,
                    BeatmapID       = item.Beatmap.OnlineID,
                    BeatmapChecksum = item.Beatmap.MD5Hash,
                    RulesetID       = item.RulesetID,
                    RequiredMods    = item.RequiredMods.ToArray(),
                    AllowedMods     = item.AllowedMods.ToArray()
                };

                Task task = itemToEdit != null?client.EditPlaylistItem(multiplayerItem) : client.AddPlaylistItem(multiplayerItem);

                task.ContinueWith(t =>
                {
                    Schedule(() =>
                    {
                        loadingLayer.Hide();

                        if (t.IsFaulted)
                        {
                            Exception exception = t.Exception;

                            if (exception is AggregateException ae)
                            {
                                exception = ae.InnerException;
                            }

                            Debug.Assert(exception != null);

                            string message = exception is HubException
                                             // HubExceptions arrive with additional message context added, but we want to display the human readable message:
                                             // "An unexpected error occurred invoking 'AddPlaylistItem' on the server.InvalidStateException: Can't enqueue more than 3 items at once."
                                             // We generally use the message field for a user-parseable error (eventually to be replaced), so drop the first part for now.
                                ? exception.Message.Substring(exception.Message.IndexOf(':') + 1).Trim()
                                : exception.Message;

                            Logger.Log(message, level: LogLevel.Important);
                            Carousel.AllowSelection = true;
                            return;
                        }

                        this.Exit();
                    });
                });
            }
            else
            {
                Playlist.Clear();
                Playlist.Add(item);
                this.Exit();
            }
        }
Beispiel #16
0
 public UCPlayListViewModel(IEventAggregator eventaggregator)
 {
     ea = eventaggregator;
     ea.GetEvent <AddPlayListEvent>().Subscribe(AddPlaylist);
     Playlist.Add(new PlayListModel {
         Name = "@han By WPF开发", DateTime = DateTime.Now
     });
 }
Beispiel #17
0
 public async Task Add(VideoItem videoItem, bool isPlayingPlaylist)
 {
     if (Playlist.FirstOrDefault(x => x.Path == videoItem.Path) != null)
     {
         return;
     }
     Playlist.Add(videoItem);
 }
Beispiel #18
0
 public void AddSong()
 {
     Console.Clear(); Console.WriteLine("\tAdd new song");
     Console.Write("title: "); string          title     = Console.ReadLine();
     Console.Write("author \nName : "); string auth_name = Console.ReadLine();
     Console.Write("age : "); string           auth_age  = Console.ReadLine();
     playlist.Add(new Song(title, new Author(auth_name, int.Parse(auth_age))));
 }
Beispiel #19
0
        protected override bool SelectItem(PlaylistItem item)
        {
            if (operationInProgress.Value)
            {
                return(false);
            }

            // If the client is already in a room, update via the client.
            // Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation.
            if (client.Room != null)
            {
                selectionOperation = operationTracker.BeginOperation();

                var multiplayerItem = new MultiplayerPlaylistItem
                {
                    ID              = itemToEdit ?? 0,
                    BeatmapID       = item.Beatmap.OnlineID,
                    BeatmapChecksum = item.Beatmap.MD5Hash,
                    RulesetID       = item.RulesetID,
                    RequiredMods    = item.RequiredMods.ToArray(),
                    AllowedMods     = item.AllowedMods.ToArray()
                };

                Task task = itemToEdit != null?client.EditPlaylistItem(multiplayerItem) : client.AddPlaylistItem(multiplayerItem);

                task.FireAndForget(onSuccess: () =>
                {
                    selectionOperation.Dispose();

                    Schedule(() =>
                    {
                        // If an error or server side trigger occurred this screen may have already exited by external means.
                        if (this.IsCurrentScreen())
                        {
                            this.Exit();
                        }
                    });
                }, onError: _ =>
                {
                    selectionOperation.Dispose();

                    Schedule(() =>
                    {
                        Carousel.AllowSelection = true;
                    });
                });
            }
            else
            {
                Playlist.Clear();
                Playlist.Add(item);
                this.Exit();
            }

            return(true);
        }
Beispiel #20
0
 public async Task Add(List <TrackItem> trackItems)
 {
     foreach (var track in trackItems)
     {
         track.Index = (uint)Playlist.Count;
         Playlist.Add(track);
     }
     var backgroundTracks = BackgroundTaskTools.CreateBackgroundTrackItemList(trackItems);
     await App.BackgroundAudioHelper.AddToPlaylist(backgroundTracks);
 }
Beispiel #21
0
        private void Instance_SongRequested(object sender, Song e)
        {
            if (!Playlist.Contains(e))
            {
                Playlist.Add(e);
                CloudService.Instance.SendSongAdded(e, Playlist.IndexOf(e));
            }

            Debug.WriteLine("Song Requested " + e.Title);
        }
Beispiel #22
0
 private async void LoadNowPlayingPlaylist()
 {
     foreach (var x in Library.Current.NowPlayingList)
     {
         Playlist.Add(x);
     }
     Scroll();
     //Playlist = Library.Current.NowPlayingList;
     //Playlist = await DatabaseManager.SelectAllSongItemsFromNowPlayingAsync();
 }
Beispiel #23
0
 private void AddPlaylist(PlayListModel obj)
 {
     try
     {
         Playlist.Add(obj);
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #24
0
        /// <summary>
        /// Создание плейлиста из коллекции фильмов/других наследников Artifact
        /// </summary>
        /// <param name="playlist">Исходная коллекция</param>
        /// <typeparam name="T">Тип элементов коллекции</typeparam>
        /// <returns>Плейлист</returns>
        public static Playlist <T> ToPlaylist <T>(this IEnumerable <T> playlist) where T : Artifact
        {
            Logger?.Log("Преобразование коллекции в плейлист");
            var result = new Playlist <T>();

            foreach (var item in playlist)
            {
                result.Add(item);
            }
            return(result);
        }
Beispiel #25
0
        private void createNewItem()
        {
            PlaylistItem item = new PlaylistItem
            {
                ID = (Playlist.LastOrDefault()?.ID + 1) ?? 0,
            };

            populateItemFromCurrent(item);

            Playlist.Add(item);
        }
Beispiel #26
0
 public void PickVideo(int videoId)
 {
     //API CALL
     if (Viewers.Contains(StateAgent.CurrentViewer) && StateAgent.CurrentViewer.Type == ViewerType.Curator)
     {
         Playlist.Add(new Video()
         {
             Id = videoId
         });
     }
 }
Beispiel #27
0
        private void createNewItem()
        {
            PlaylistItem item = new PlaylistItem
            {
                ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1
            };

            populateItemFromCurrent(item);

            Playlist.Add(item);
        }
Beispiel #28
0
 public async Task Add(TrackItem trackItem, bool isPlayingPlaylist)
 {
     if (Playlist.FirstOrDefault(x => x.Id == trackItem.Id) != null)
     {
         return;
     }
     trackItem.Index = (uint)Playlist.Count;
     Playlist.Add(trackItem);
     var backgroundTrack = BackgroundTaskTools.CreateBackgroundTrackItem(trackItem);
     await App.BackgroundAudioHelper.AddToPlaylist(backgroundTrack);
 }
Beispiel #29
0
 private void Awake()
 {
     AudioSource = GetComponent <AudioSource>();
     m_playlist  = new Playlist(m_tracks);
     if (AudioSource.clip)
     {
         m_playlist.Add(AudioSource.clip);
     }
     AudioSource.playOnAwake = false;
     AudioSource.clip        = null;
     AudioSource.loop        = false;
 }
Beispiel #30
0
        private void createNewItem()
        {
            PlaylistItem item = new PlaylistItem(Beatmap.Value.BeatmapInfo)
            {
                ID           = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1,
                RulesetID    = Ruleset.Value.OnlineID,
                RequiredMods = Mods.Value.Select(m => new APIMod(m)).ToArray(),
                AllowedMods  = FreeMods.Value.Select(m => new APIMod(m)).ToArray()
            };

            Playlist.Add(item);
        }
Beispiel #31
0
 /// <summary>
 /// 更新后台音频播放列表
 /// </summary>
 /// <param name="songs">更新的歌曲信息</param>
 /// <param name="isResumed">是否是第一次更新列表</param>
 public void UpdatePlaybackList(List <SongModel> songs, bool isResumed)
 {
     MessageService.SendMessageToBackground(new UpdatePlaybackListMessage(songs, isResumed));
     Playlist.Clear();
     foreach (var song in songs)
     {
         Playlist.Add(song);
     }
     PlaylistChanged?.Invoke(this, new PlaylistChangedEventArgs()
     {
         NewList = songs
     });
 }
        protected override Playlist normalize(List<String> raw)
        {
            Playlist normalized = new Playlist();

            for(int i = 0; i < raw.Count; i++)
            {
                string line = raw[i];
                if (!line.StartsWith("#"))
                {
                    if (File.Exists(Path.GetFullPath(pathPrefix + Path.DirectorySeparatorChar + raw[i])))
                    {
                        PlaylistItem item = new PlaylistItem(raw[i], pathPrefix);
                        normalized.Add(item);
                    }
                }
            }

            return normalized;
        }