Ejemplo n.º 1
0
        public void StorePlaylist()
        {
            string           playlistDir = Path.Combine(OutputPath, "StorePlaylist");
            IPlaylistHandler handler     = new LegacyPlaylistHandler();

            if (Directory.Exists(playlistDir))
            {
                Directory.Delete(playlistDir, true);
            }
            Assert.IsFalse(Directory.Exists(playlistDir));

            PlaylistManager manager  = new PlaylistManager(playlistDir, handler);
            var             songs    = CreateSongArray <LegacyPlaylistSong>("Legacy_", "LegacyAuthor_", 1000, Identifier.LevelId | Identifier.Hash | Identifier.Key);
            IPlaylist       playlist = manager.CreatePlaylist("5LegacySongs", "Five Legacy Songs", "TestAuthor", string.Empty, "Test Description");

            foreach (var song in songs)
            {
                playlist.Add(song);
            }
            playlist.RaisePlaylistChanged();
            manager.RegisterPlaylist(playlist);
            Assert.IsTrue(manager.IsPlaylistChanged(playlist));
            manager.StoreAllPlaylists();
            Assert.IsFalse(manager.IsPlaylistChanged(playlist));
            playlist.Add(songs[0]);
            playlist.RaisePlaylistChanged();
            Assert.IsTrue(manager.IsPlaylistChanged(playlist));
            if (Directory.Exists(playlistDir))
            {
                Directory.Delete(playlistDir, true);
            }
        }
Ejemplo n.º 2
0
        public void TestPlaylistBasics()
        {
            BmpSong song = LoadTestSong();

            Assert.IsNull(song.Id);

            using (BmpCoffer test = this.CreateCofferManager())
            {
                test.SaveSong(song);
                Assert.IsNotNull(song.Id);

                IPlaylist playlist = test.CreatePlaylist(PLAYLIST_NAME);
                Assert.IsNotNull(playlist);
                Assert.IsTrue(playlist is BmpPlaylistDecorator);
                Assert.AreEqual(PLAYLIST_NAME, playlist.GetName());

                // Internal things...
                BmpPlaylist backingData = ((BmpPlaylistDecorator)playlist).GetBmpPlaylist();
                Assert.IsNull(backingData.Id);

                playlist.Add(song);

                test.SavePlaylist(playlist);
                Assert.IsNotNull(backingData.Id);

                IPlaylist result = test.GetPlaylist(PLAYLIST_NAME);
                Assert.IsNotNull(result);
                Assert.AreEqual(backingData.Id, ((BmpPlaylistDecorator)playlist).GetBmpPlaylist().Id);
            }
        }
Ejemplo n.º 3
0
        public void GetCount()
        {
            //arrange
            _fixture = new Playlist("TestPlaylist", "Ganfalf", DateTime.Now);

            var mockedItem1 = new Mock <IPlaylistItems>();
            var mockedItem2 = new Mock <IPlaylistItems>();

            _fixture.Add(mockedItem1.Object); //un objeto de la clase IplaylistItems
            _fixture.Add(mockedItem2.Object);

            //act
            var count = _fixture.Count;

            //assert
            Assert.That(count, Is.EqualTo(2));
        }
Ejemplo n.º 4
0
        public void GetDuration()
        {
            //arrange
            _fixture = new Playlist("TestPlaylist", "Ganfalf", DateTime.Now);

            var mockedItem1 = new Mock <IPlaylistItems>();

            mockedItem1.Setup(x => x.Duration).Returns(TimeSpan.FromSeconds(5));//lambda expresion sirve para simular la duracion con ayuda del mocked

            var mockedItem2 = new Mock <IPlaylistItems>();

            mockedItem2.Setup(x => x.Duration).Returns(TimeSpan.FromSeconds(65));

            _fixture.Add(mockedItem1.Object); //un objeto de la clase IplaylistItems
            _fixture.Add(mockedItem2.Object);

            //act
            var duration = _fixture.Duration;

            //assert
            Assert.That(duration, Is.EqualTo(TimeSpan.FromSeconds(70)));
        }
Ejemplo n.º 5
0
        public void GetCount()
        {
            //arrange
            var mockedItem1 = new Mock <IPlaylistItem.IPlaylistItem>();
            var mockedItem2 = new Mock <IPlaylistItem.IPlaylistItem>();

            _fixture.Add(mockedItem1.Object);
            _fixture.Add(mockedItem2.Object);

            //act
            var count = _fixture.Count;

            //assert
            Assert.That(count, Is.EqualTo(2));
        }
Ejemplo n.º 6
0
        public static IPlaylist CreatePlaylist <T, TSong>(string fileName, string title, string author, int numSongs,
                                                          string?description = null, string?suggestedExtension = null)
            where T : IPlaylistHandler, new()
            where TSong : IPlaylistSong, new()
        {
            T         handler  = new T();
            IPlaylist playlist = handler.CreatePlaylist(fileName, title, author, description, suggestedExtension);

            TSong[] songs = CreateSongArray <TSong>(fileName + "_", author + "_", numSongs, Identifier.Hash | Identifier.Key, fileName);
            for (int i = 0; i < songs.Length; i++)
            {
                playlist.Add(songs[i]);
            }
            playlist.RaisePlaylistChanged();
            return(playlist);
        }
Ejemplo n.º 7
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in openFileDialog1.FileNames)
            {
                var item = _playlistItemFactory.Create(file);
                if (item != null)
                {
                    _playlist.Add(item);
                }
            }
        }
Ejemplo n.º 8
0
        private void itemsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "MP3 File (*.mp3)|*.mp3";
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in openFileDialog1.FileNames)
            {
                var item = _playlistItemFactory.Create(file);
                if (item != null)
                {
                    _playlist.Add(item);
                }
            }

            UpdatePlaylistDetails();
            UpdatePlaylistItems();
        }
        public void StartPartyMode()
        {
            ServiceRegistration.Get <ILogger>().Info("PartyMusicPlayerModel: Starting party mode");
            SaveSettings();
            if (!LoadPlaylist())
            {
                return;
            }

            LoadPlayRepeatMode();

            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        audioPlayerContext = pcm.OpenAudioPlayerContext(Consts.MODULE_ID_PARTY_MUSIC_PLAYER, Consts.RES_PLAYER_CONTEXT_NAME, false,
                                                                                  Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER, Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER);
            IPlaylist playlist = audioPlayerContext.Playlist;

            playlist.StartBatchUpdate();
            try
            {
                playlist.Clear();
                foreach (MediaItem mediaItem in _mediaItems)
                {
                    playlist.Add(mediaItem);
                }
                playlist.PlayMode   = PlayMode;
                playlist.RepeatMode = RepeatMode;
                _playerContext      = audioPlayerContext;
            }
            finally
            {
                playlist.EndBatchUpdate();
            }

            audioPlayerContext.Play();

            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            workflowManager.NavigatePushAsync(Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER);
        }
Ejemplo n.º 10
0
        public void TestPlaylistListing()
        {
            BmpSong song = LoadTestSong();

            Assert.IsNull(song.Id);

            using (BmpCoffer test = this.CreateCofferManager())
            {
                test.SaveSong(song);
                Assert.IsNotNull(song.Id);

                IPlaylist playlist = test.CreatePlaylist(PLAYLIST_NAME);
                Assert.IsNotNull(playlist);

                playlist.Add(song);

                test.SavePlaylist(playlist);

                IList <string> names = test.GetPlaylistNames();
                Assert.AreEqual(1, names.Count);
                Assert.AreEqual(playlist.GetName(), names[0]);
            }
        }
Ejemplo n.º 11
0
 public void AddToPlaylist(string[] filePath)
 {
     _playlist.Add(filePath);
 }
Ejemplo n.º 12
0
        /*      CREATE                       */

        /* ----------------
         * AddPlaylistViewModel playlist
         * ----------------- */
        public void Add(AddPlaylistViewModel addingPlaylist)
        {
            _services.Add(addingPlaylist);
            return;
        }