示例#1
0
        private void Header_Tapped(object sender, TappedRoutedEventArgs e)
        {
            pivot.Opacity = 1.0;

            string header = ((TextBlock)((Border)sender).Child).Text;

            Popup.IsOpen = false;
            navigationHelper.BlockBackStateTemporarily = null;

            if ((string)Popup.Tag == "Artist")
            {
                GroupInfoList <Artist> group = MusicLibrary.GetItemGroup(MusicLibrary.Instance.ArtistGroupDictionary, header);

                lvArtists.ScrollIntoView(group[0], ScrollIntoViewAlignment.Leading);
            }
            else if ((string)Popup.Tag == "Album")
            {
                GroupInfoList <Album> group = MusicLibrary.GetItemGroup(MusicLibrary.Instance.AlbumGroupDictionary, header);

                lvAlbums.ScrollIntoView(group[0], ScrollIntoViewAlignment.Leading);
            }
            else if ((string)Popup.Tag == "Song")
            {
                GroupInfoList <Song> group = MusicLibrary.GetItemGroup(MusicLibrary.Instance.SongGroupDictionary, header);

                lvSongs.ScrollIntoView(group[0], ScrollIntoViewAlignment.Leading);
            }
        }
示例#2
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            soundsLibrary = GetComponent <SoundLibrary>();
            musicLibrary  = GetComponent <MusicLibrary>();

            musicSource = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("MusicSource" + (i + 1));
                musicSource[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            GameObject newSfxSource = new GameObject("2D sfx source");
            sfxSource = newSfxSource.AddComponent <AudioSource>();
            newSfxSource.transform.parent = transform;

            masterVolumen = PlayerPrefs.GetFloat(AudioChannel.Master.ToString(), 1f);
            sfxVolumen    = PlayerPrefs.GetFloat(AudioChannel.Sfx.ToString(), 1);
            musicVolumen  = PlayerPrefs.GetFloat(AudioChannel.Music.ToString(), 1f);
        }
    }
示例#3
0
 private void LoadSongsInBG(object folderPath)
 {
     _library = new MusicLibrary {
         Songs = FolderHelper.GetSongs((string)folderPath)
     };
     lblSongCount.Dispatcher.Invoke(new Action(delegate { lblSongCount.Content = _library.Songs.Count + " files found"; }));
 }
示例#4
0
        /// <summary>
        /// Gets called when the App suspends
        /// </summary>
        private async void OnAppSuspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
        {
            Orchestra.Disconnect();
            await MusicLibrary.Save();

            MusicLibrary.Close();
        }
示例#5
0
        private void btnRemoveLibrary_Click(object sender, RoutedEventArgs e)
        {
            string sMessageBoxText = "Are you sure you want to delete the library " + selectedLibrary.LibraryName + "?";
            string sCaption        = "Delete Library";

            MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
            MessageBoxImage  icnMessageBox = MessageBoxImage.Warning;

            MessageBoxResult result = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    MusicLibrary.DeleteLibrary(selectedLibrary.LibraryName);
                    libraries.Remove((MusicLibrary)lstLibraries.SelectedItem);
                    lstLibraries.Items.Refresh();
                    if (lstLibraries.Items.Count > 0)
                    {
                        lstLibraries.SelectedItem = lstLibraries.Items[0];
                        selectedLibrary           = (MusicLibrary)lstLibraries.SelectedItem;
                    }
                    else
                    {
                        selectedLibrary = null;
                    }
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
        }
示例#6
0
        void btnAddLibrary_Click(object sender, RoutedEventArgs e)
        {
            string libraryRoot;
            string libraryName;

            InputDialog iDialog = new InputDialog("Please give this library a name: ", "");

            if (iDialog.ShowDialog() == true)
            {
                libraryName = iDialog.Answer;

                FolderBrowser fb = new FolderBrowser();
                fb.IncludeFiles = false;
                fb.Description  = "Please select root folder for library";
                if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    libraryRoot = fb.SelectedPath;
                    MusicLibrary ml = new MusicLibrary(libraryName, libraryRoot);
                    ml.StatusChangedEvent += HandleStatusChangedEvent;

                    Thread MyNewThread = new Thread(new ThreadStart(() =>
                    {
                        ml.CreateLibrary();
                    }));
                    MyNewThread.Start();

                    libraries.Add(ml);
                    lstLibraries.Items.Refresh();
                    lstLibraries.SelectedItem = ml;
                    selectedLibrary           = ml;
                }
            }
        }
示例#7
0
        public MainWindow()
        {
            _library = new MusicLibrary(@"D:\Temp\mymusic.dat");
            try
            {
                _library.Load();
            }
            catch (SecurityException)
            {
            }
            catch (IOException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }

            InitializeComponent();
            DataContext = _fileSystemContext;

            devicesComboBox.Items.Add("D:\\Temp\\1");
            devicesComboBox.Items.Add("D:\\Temp\\2");

            applyMode();
        }
示例#8
0
        public void GivenUnparsedResponse_WhenMultipleItemsAreReturned_ThenTheyShouldBeParsedCorrectly()
        {
            var htmlResponse1 = new string[3];

            htmlResponse1[0] = "<a href=\"https://www.metal-archives.com/bands/%21T.O.O.H.%21/16265\" title=\"!T.O.O.H.! (CZ)\">!T.O.O.H.!</a>";
            htmlResponse1[1] = "<a href=\"https://www.metal-archives.com/albums/%21T.O.O.H.%21/Democratic_Solution/384622\">Democratic Solution</a> <!-- 7.792132 -->";
            htmlResponse1[2] = "Full-Length";

            var htmlResponse2 = new string[3];

            htmlResponse2[0] = "<a href=\"https://www.metal-archives.com/bands/%21T.O.O.H.%21/16265\" title=\"!T.O.O.H.! (CZ)\">!T.O.O.H.!</a>";
            htmlResponse2[1] = "<a href=\"https://www.metal-archives.com/albums/%21T.O.O.H.%21/Democratic_Solution/384622\">wacky demo name (demo)</a> <!-- 7.792132 -->";
            htmlResponse2[2] = "demo";

            var maResponse = new MetalArchivesResponse();

            maResponse.aaData    = new string[2][];
            maResponse.aaData[0] = htmlResponse1;
            maResponse.aaData[1] = htmlResponse2;

            MusicLibrary l = _parser.Parse(maResponse);

            Assert.AreEqual(2, l.Collection.Count);

            Assert.AreEqual(1, l.Artists.Count);
            Assert.AreEqual("!T.O.O.H.!", l.Artists[0].ArtistName);
            Assert.AreEqual("CZ", l.Artists[0].Country);

            Assert.AreEqual(2, l.Releases.Count);
            Assert.AreEqual("Democratic Solution", l.Releases[0].ReleaseName);
            Assert.AreEqual(true, l.Releases[0].IsFullLength);

            Assert.AreEqual("wacky demo name", l.Releases[1].ReleaseName);
            Assert.AreEqual(false, l.Releases[1].IsFullLength);
        }
 public MusicLibrary Filter(MusicLibrary original, MetalArchivesRequest request)
 {
     // looks like without the FindAll below, MA is returning any artists whose names even slightly match our request
     // ensuring that the discovered artistname starts the same as the desired artistname helps prevent this
     return new MusicLibrary(original.Collection
         .FindAll(x => x.ArtistData.ArtistName.StartsWith(request.ArtistName))
         .FindAll(x => x.ReleaseData.IsFullLength));
 }
示例#10
0
 public async Task <StorageFolder> AddFolderToLibraryAsync()
 {
     if (MusicLibrary != null)
     {
         return(await MusicLibrary.RequestAddFolderAsync());
     }
     return(null);
 }
示例#11
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var files = await MusicLibrary.GetSongFiles();

            ArtistList = await MusicLibrary.GetArtistList();

            lvArtists.ItemsSource = ArtistList;
        }
示例#12
0
 private void lstLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lstLibraries.SelectedIndex == -1)
     {
         return;
     }
     selectedLibrary = (MusicLibrary)lstLibraries.SelectedItem;
     OnRaiseSelectedLibraryChangedEvent(new SelectedLibraryChangedEventArgs(selectedLibrary));
     Properties.Settings.Default.SelectedLibraryName = selectedLibrary.LibraryName;
     Properties.Settings.Default.Save();
 }
示例#13
0
        private async void LvPlaylist_ItemClick(object sender, ItemClickEventArgs e)
        {
            //Get Selected Item
            MusicLibrary song = (MusicLibrary)e.ClickedItem;
            StorageFile  file = await StorageFile.GetFileFromPathAsync(song.Path);

            //code to play song from song.MusicPath
            IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read);

            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.Source   = MediaSource.CreateFromStream(readStream, file.ContentType);;
            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.AutoPlay = true;
        }
示例#14
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to Draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            animations   = new AnimationLibrary(Content);
            musicLibrary = new MusicLibrary(Content);
            saltCircle   = Content.Load <Texture2D>("sprites/select_circle");

            font = Content.Load <SpriteFont>("fonts/arial");

            musicLibrary.play(MusicLibrary.HEROIC_DEMISE);
        }
示例#15
0
 private void MusicWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     Console.WriteLine($"Worker Completed!");
     if (e.Result != null)
     {
         library = (MusicLibrary)e.Result;
     }
     else
     {
         Console.WriteLine("### Error loading Music Library, stopping!");
         Stop();
     }
 }
示例#16
0
 public ucLibraryManager()
 {
     InitializeComponent();
     libraries = MusicLibrary.GetAvailableLibraries();
     lstLibraries.ItemsSource = libraries;
     try
     {
         lstLibraries.SelectedItem = libraries.Find(x => x.LibraryName == Properties.Settings.Default.SelectedLibraryName);
     }
     catch (Exception e)
     {
         Console.WriteLine("Could not load selected library: " + e.Message);
     }
 }
示例#17
0
        public MusicLibraryTests()
        {
            _mockDataLoader        = new LibraryDbMockGenerator();
            _musicLibraryDbContext = _mockDataLoader.DbContextMock;

            var settings      = A.Fake <IDukeboxSettings>();
            var albumArtCache = A.Fake <IAlbumArtCacheService>();
            var audioFormats  = new AudioFileFormats();

            A.CallTo(() => settings.AddDirectoryConcurrencyLimit).Returns(20);

            audioFormats.SupportedFormats.Add(".mp3");

            _musicLibrary = new MusicLibrary(_musicLibraryDbContext, settings, albumArtCache, audioFormats);
        }
        public void GivenAnEmptyDirectoryOnDisk_WhenParsedIntoAMusicLibrary_ThenMusicLibraryShouldBeEmpty()
        {
            // use a new directory on disk that has no content
            var libraryPath = new DirectoryInfo("C:\\iExistButAmEmpty");

            // TODO: I guess this could fail if the folder already exists on disk...
            libraryPath.Create();

            var l = new MusicLibrary(libraryPath);

            Assert.AreEqual(l.Collection.Count, 0);
            Assert.AreEqual(l.Artists.Count, 0);
            Assert.AreEqual(l.Releases.Count, 0);

            // TODO: I guess this could leave the folder on disk if the Assert above fails...
            libraryPath.Delete();
        }
示例#19
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var files = await MusicLibrary.GetSongFiles();

            ObservableCollection <MusicLibrary> MusicList = new ObservableCollection <MusicLibrary>();

            foreach (var file in files)
            {
                //get file/song property
                StorageItemThumbnail currentThumb = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 200, ThumbnailOptions.UseCurrentScale);

                var albumCover = new BitmapImage();
                albumCover.SetSource(currentThumb);
                var musicProperties = await file.Properties.GetMusicPropertiesAsync();

                var title  = musicProperties.Title;
                var artist = musicProperties.Artist;
                var album  = musicProperties.Album;

                //build songs list
                MusicLibrary newSong = new MusicLibrary
                {
                    Filename = file.Name,
                    Title    = title,
                    Artist   = artist,
                    Album    = album,
                    Path     = file.Path
                };

                if (!MusicList.Contains(newSong))
                {
                    MusicList.Add(newSong);
                }
                ;

                MediaPlaybackItem item = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(file));
                mpl.Items.Add(item);
            }

            IEnumerable <MusicLibrary> sortedAlbum = MusicList.OrderBy(o => o.Title);

            myList.ItemsSource = sortedAlbum;
            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.Source   = mpl;
            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.AutoPlay = false;
        }
        public static object GetMusicLibraryFileTypeValue(this AudioFileType type, MusicLibrary library)
        {
            var musicLibraryFileTypeAttribute = typeof(AudioFileType).GetField(type.ToString())?.GetCustomAttribute <MusicLibraryFileTypeValue>();

            if (musicLibraryFileTypeAttribute == null)
            {
                throw new Exception($"AudioFileType enum's field {type.ToString()} is not updated with the proper MusicLibraryFileTypeValue attribute");
            }

            switch (library)
            {
            case MusicLibrary.Clementine:
                return(musicLibraryFileTypeAttribute.Clementine);

            default:
                return(null);
            }
        }
示例#21
0
        private static IMusicLibrary GetMusicLibraryInstance(Container container)
        {
            try
            {
                EnsureLocalEnvironmentValid();

                var musicLibrary = new MusicLibrary(container.GetInstance <IMusicLibraryDbContext>(), container.GetInstance <IDukeboxSettings>(),
                                                    container.GetInstance <IAlbumArtCacheService>(), container.GetInstance <AudioFileFormats>());

                return(musicLibrary);
            }
            catch (Exception ex)
            {
                var errMsg = "Error opening SQLite music library database";

                logger.Error(errMsg, ex);
                throw new Exception(errMsg, ex);
            }
        }
        public void GivenANonEmptyDirectoryOnDisk_WhenParsedIntoAMusicLibrary_ThenMusicLibraryShouldBePopulated()
        {
            // TODO: I guess this could fail if the folders already exist on disk...
            var rootPath = new DirectoryInfo("C:\\iExist");

            rootPath.Create();

            var a1path = new DirectoryInfo(rootPath + "\\artist1");

            a1path.Create();
            var a2path = new DirectoryInfo(rootPath + "\\artist2");

            a1path.Create();

            var a1r1path = new DirectoryInfo(a1path + "\\release1");

            a1r1path.Create();
            var a1r2path = new DirectoryInfo(a1path + "\\release2");

            a1r2path.Create();
            var a2r1path = new DirectoryInfo(a2path + "\\release1");

            a2r1path.Create();
            var a2r2path = new DirectoryInfo(a2path + "\\release2");

            a2r2path.Create();

            var l = new MusicLibrary(rootPath);

            Assert.AreEqual(l.Collection.Count, 4);
            Assert.AreEqual(l.Artists.Count, 2);
            Assert.AreEqual(l.Releases.Count, 4);

            // TODO: I guess this could leave the folders on disk if the Assert above fails...
            a1r1path.Delete();
            a1r2path.Delete();
            a2r1path.Delete();
            a2r2path.Delete();
            a1path.Delete();
            a2path.Delete();
            rootPath.Delete();
        }
示例#23
0
        //-------------------------------------------------------------------------------------
        // Method
        //-------------------------------------------------------------------------------------
        /// <summary>
        /// Use this for initialization
        /// </summary>
        void Start()
        {
            // フォルダ、曲ファイルの検索、ライブラリ構築
            this.library = new MusicLibrary(songsFolderPath);

            // stateの初期状態
            this.state = EState.FolderSelect;

            // インスタンス生成
            this.button = new UnityEngine.UI.Button[MAX_VIEW_LIST];
            for (int i = 0; i < MAX_VIEW_LIST; ++i)
            {
                this.button[i] = Instantiate(this.Pref_Button);                     // プレハブからインスタンス生成
                button[i].transform.SetParent(GameObject.Find("Canvas").transform); // Canvasの子でないと表示されない
                // ボタンにイベントを登録する.
                int n = i;                                                          // スコープの関係で i を n に一度代入する
                button[i].onClick.AddListener(() => this.OnButtonSelected(button[n]));
            }

            // 最初はフォルダセレクトを表示する
            this.FolderSelectSetup();
        }
示例#24
0
        public MainWindow()
        {
            _isPlaying = false;
            InitializeComponent();

            //keyboard shortcuts
            KeyCommands.PlayPauseCommand.InputGestures.Add(new KeyGesture(Key.Space));
            KeyCommands.NextTrackCommand.InputGestures.Add(new KeyGesture(Key.Right));
            KeyCommands.PreviousTrackCommand.InputGestures.Add(new KeyGesture(Key.Left));
            KeyCommands.VolumeDownCommand.InputGestures.Add(new KeyGesture(Key.Down));
            KeyCommands.VolumeUpCommand.InputGestures.Add(new KeyGesture(Key.Up));

            _library           = new MusicLibrary();
            volumeSlider.Value = 1.00;
            RefreshVolumeValueDisplay();
            var md = Settings.Default.MusicDirectory;

            if (!string.IsNullOrEmpty(md) && md != "None")
            {
                LoadSongs(md);
            }
        }
示例#25
0
        private async void LvAlbums_ItemClick(object sender, ItemClickEventArgs e)
        {
            var ml = (MusicLibrary)e.ClickedItem;
            var album = ml.Album;
            var files = await MusicLibrary.GetSongFiles();

            ObservableCollection<MusicLibrary> MusicList = new ObservableCollection<MusicLibrary>();

            foreach (var file in files)
            {
                //get file/song property
                var musicProperties = await file.Properties.GetMusicPropertiesAsync();
                var title = musicProperties.Title;
                var artist = musicProperties.Artist;

                if (musicProperties.Album == album)
                {
                    MediaPlaybackItem item = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(file));
                    mpl.Items.Add(item);

                    //build songs list
                    MusicList.Add(new MusicLibrary
                    {
                        Filename = file.Name,
                        Title = title,
                        Artist = artist,
                        Album = album,
                        Path = file.Path
                    });
                }
            }
            lvSongsByAlbum.ItemsSource = MusicList;
            lvSongsByAlbum.Visibility = Visibility.Visible;
            lvAlbums.Visibility = Visibility.Collapsed;
            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.Source = mpl;
            ((Window.Current.Content as Frame).Content as MainPage).mediaPlayer.AutoPlay = false;

        }
示例#26
0
        private ILibrary GetLibrary(Directory dir, CancellationToken token)
        {
            var      type = GetTypeFromString(dir.Type);
            ILibrary library;

            switch (type)
            {
            case LibraryType.Movie:
                library = new MovieLibrary
                {
                    GetMoviesAsync      = (cancellationToken) => GetMoviesAsync(dir.Key, cancellationToken),
                    GetCollectionsAsync = (cancellationToken) => GetCollectionsAsync(dir.Key, cancellationToken)
                };
                break;

            case LibraryType.Music:
                library = new MusicLibrary
                {
                    GetAlbumsAsync      = (cancellationToken) => GetAlbumsAsync(dir.Key, cancellationToken),
                    GetCollectionsAsync = (cancellationToken) => GetCollectionsSimpleAsync(dir.Key, cancellationToken)
                };
                break;

            default:
                library = new OtherLibrary
                {
                    GetCollectionsAsync = (cancellationToken) => GetCollectionsAsync(dir.Key, cancellationToken)
                };
                break;
            }
            library.Id        = dir.Key;
            library.Poster    = $"{Configuration.ServerAddress}{dir.Art}?{Configuration.QueryStringPlexToken}";
            library.Thumbnail = $"{Configuration.ServerAddress}{dir.Thumb}?{Configuration.QueryStringPlexToken}";
            library.Title     = dir.Title;
            return(library);
        }
示例#27
0
 private void Awake()
 {
     library = MusicPlayer.Instance.library;
 }
示例#28
0
 public IntelligentPlaylist(string name, MusicLibrary library) : base(name)
 {
     this.library = library;
 }
示例#29
0
        public MusicLibrary OpenLibrary()
        {
            var lib = new MusicLibrary(LibraryDBPath);

            return(lib);
        }
示例#30
0
        private void MusicWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MusicLibrary library = new MusicLibrary();

            foreach (string FilePath in getAllFilesSubSearch(MusicDirectoryPath, Resources.SupportedFileFormats))
            {
                AlbumArtist albumArtist = null;
                Album       album       = null;

                using (TagLib.File tagFile = TagLib.File.Create(FilePath))
                {
                    MusicFile music = new MusicFile(FilePath)
                    {
                        Title     = tagFile.Tag.Title,
                        Performer = tagFile.Tag.FirstPerformer,
                        Disc      = tagFile.Tag.Disc,
                        Track     = tagFile.Tag.Track,
                        Year      = tagFile.Tag.Year,
                    };

                    if (tagFile.Tag.FirstAlbumArtist != null && tagFile.Tag.Album != null)
                    {
                        albumArtist = library.AlbumArtists.Find(x => x.Name.Equals(tagFile.Tag.FirstAlbumArtist, StringComparison.OrdinalIgnoreCase));
                        if (albumArtist == null)
                        {
                            albumArtist = new AlbumArtist()
                            {
                                Name = tagFile.Tag.FirstAlbumArtist
                            };
                            library.AlbumArtists.Add(albumArtist);
                        }

                        album = library.Album.Find(x => x.Name.Equals(tagFile.Tag.Album, StringComparison.OrdinalIgnoreCase));
                        if (album == null)
                        {
                            album = new Album()
                            {
                                AlbumArtist = albumArtist.GUID, Name = tagFile.Tag.Album
                            };
                            library.Album.Add(album);

                            albumArtist.AlbumID.Add(album.GUID);
                        }

                        music.Album       = album.GUID;
                        music.AlbumArtist = albumArtist.GUID;

                        if (music.Disc > album.DiscCount)
                        {
                            album.DiscCount = music.Disc;
                        }

                        if (music.Track > album.TrackCount)
                        {
                            album.TrackCount = music.Track;
                        }

                        album.MusicFiles.Add(music.GUID);
                        albumArtist.MusicFileIDs.Add(music.GUID);
                    }

                    library.MusicFiles.Add(music);
                }
            }

            // TODO: Media Player Playlist parsen und in neues Format

            e.Result = library;
        }
示例#31
0
 void HandleSelectedLibraryChangedEvent(object sender, SelectedLibraryChangedEventArgs slcea)
 {
     selectedLibrary = slcea.SelectedLibrary;
     playlistEditorControl.SelectedLibrary = selectedLibrary;
     playerControl.SelectedLibrary         = selectedLibrary;
 }