コード例 #1
0
        public void UpdatePlaylistFromStrings(Playlist playlist, IEnumerable <string> collection)
        {
            if (collection is null || playlist is null)
            {
                return;
            }
            using (BackgroundWorker worker = new BackgroundWorker())
            {
                worker.RunWorkerAsync(new object[] { playlist, collection });
                worker.DoWork             += DoUpdatePlaylist;
                worker.RunWorkerCompleted += (s, e) =>
                {
                    if (e.Result is null)
                    {
                        return;
                    }

                    foreach (SongInfo song in e.Result as IEnumerable <SongInfo> )
                    {
                        // add new songs to library and current displayed song collection
                        if (PlaylistLibrary.SongLocations.Add(song.Uri.LocalPath) || AllSongs.Count < PlaylistLibrary.SongLocations.Count)
                        {
                            AllSongs.Add(song);
                            Helpers.ConsoleLogger.Info($"Added {song.Uri.LocalPath} to {PlaylistLibrary.Name}");
                            Helpers.ConsoleLogger.Info($"Added {song.Title} is added to AllSongCollection");
                        }
                        if (!ReferenceEquals(AllSongs, CurrentSongCollection))
                        {
                            CurrentSongCollection.Add(song);
                        }
                    }
                };
            }
        }
コード例 #2
0
        public void Initialize()
        {
            // Create Playlists and Library directory
            if (!Directory.Exists(PlaylistDir))
            {
                Directory.CreateDirectory(PlaylistDir);
            }
            if (!Directory.Exists(SongDir))
            {
                Directory.CreateDirectory(SongDir);
            }

            // load playlists from playlist directory
            GetPlaylistFiles();

            // load songs from library.xml or Library directory
            string library = Path.Combine(Environment.CurrentDirectory, "library.xml");

            if (File.Exists(library))
            {
                PlaylistLibrary = LoadPlaylistFromXmlFile(library);
            }
            else
            {
                PlaylistLibrary = CreatePlaylistFromDirectory("library.xml", Path.Combine(Environment.CurrentDirectory, SongDir));
            }
            if (PlaylistLibrary != null)
            {
                BackgroundWorker worker = new BackgroundWorker();
                LoadSongsFromPlaylist(PlaylistLibrary).ContinueWith((task) =>
                {
                    IEnumerable <SongInfo> songs = task.Result;
                    foreach (SongInfo item in songs)
                    {
                        AllSongs.Add(item);
                    }
                    CurrentSelectedPlaylistFile = PlaylistLibrary;
                    CurrentSongCollection       = AllSongs;
                });
            }

            // init media player
            mMediaPlayer.MediaOpened     += MediaOpened;
            mMediaPlayer.MediaEnded      += MediaEnded;
            mMediaPlayer.MediaFailed     += MediaFailed;
            mMediaPlayer.LoadedBehavior   = MediaState.Manual;
            mMediaPlayer.UnloadedBehavior = MediaState.Stop;
            mMediaPlayer.Play();

            // init timer to update song's position
            mSongTimer = new Timer()
            {
                Enabled  = true,
                Interval = 1000.0 / 60.0
            };
            mSongTimer.Elapsed += TimerUpdateSongPosition;
        }
コード例 #3
0
ファイル: SongList.cs プロジェクト: sethura/vocadb
        public virtual SongInList AddSong(Song song, int order, string notes)
        {
            ParamIs.NotNull(() => song);

            var link = new SongInList(song, this, order, notes);

            AllSongs.Add(link);
            return(link);
        }
コード例 #4
0
ファイル: Album.cs プロジェクト: ffdd270/vocadb
        public virtual SongInAlbum AddSong(string songName, int trackNum, int discNum)
        {
            ParamIs.NotNullOrEmpty(() => songName);

            var track = new SongInAlbum(songName, this, trackNum, discNum);

            AllSongs.Add(track);

            return(track);
        }
コード例 #5
0
ファイル: Album.cs プロジェクト: ffdd270/vocadb
        public virtual SongInAlbum AddSong(Song song, int trackNum, int discNum)
        {
            ParamIs.NotNull(() => song);

            var track = new SongInAlbum(song, this, trackNum, discNum);

            AllSongs.Add(track);
            song.AllAlbums.Add(track);

            return(track);
        }
コード例 #6
0
ファイル: Artist.cs プロジェクト: sethura/vocadb
        public virtual ArtistForSong AddSong(Song song, bool support, ArtistRoles roles)
        {
            ParamIs.NotNull(() => song);

            var link = new ArtistForSong(song, this, support, roles);

            AllSongs.Add(link);
            song.AllArtists.Add(link);

            return(link);
        }
コード例 #7
0
ファイル: PartyService.cs プロジェクト: intevent/intevent-web
        public void Reset(IEnumerable <Song> songs, Song currentlyPlaying)
        {
            Logger.LogDebug("PartyService: Reset");
            Console.WriteLine("PartyService: Reset");

            AllSongs.Clear();
            foreach (Song song in songs)
            {
                AllSongs.Add(song);
            }

            AllVotes.Clear();
            CanVote          = true;
            CurrentlyPlaying = currentlyPlaying;

            SongListingStream.OnNext(GenerateSongListing(AllSongs, CurrentlyPlaying));
            VotingResultsStream.OnNext(GenerateVotingResults(AllSongs, AllVotes, CanVote));
        }
コード例 #8
0
        public static void LoadAndSortSongs()
        {
            IEnumerable <string> songFiles = Directory.EnumerateFiles(@"C:\Users\mathewtraylor\Downloads", "*.*", SearchOption.AllDirectories)
                                             .Where(f => f.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase) || f.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase));

            foreach (string filename in songFiles)
            {
                AllSongs.Add(new Song(filename));
            }

            IEnumerable <IGrouping <string, Song> > artists = AllSongs.GroupBy(s => s.Artists);

            foreach (IGrouping <string, Song> artist in artists)
            {
                Artists.Add(new Artist(artist.Key, artist.Count()));
            }

            IEnumerable <IGrouping <string, Song> > albums = AllSongs.GroupBy(s => s.Album);

            foreach (IGrouping <string, Song> album in albums)
            {
                Albums.Add(new Album(album.Key, album.Count()));
            }
        }
コード例 #9
0
 public void Add(Song song)
 {
     AllSongs.Add(song);
 }