private Client.Common.Models.PlaylistItem CreatePlaylistItemFromSong(Song result)
        {
            var playlistItem = new Client.Common.Models.PlaylistItem();

            playlistItem.InitializeFromSong(result, SubsonicService);

            return(playlistItem);
        }
        public void HandleStartPlayback_Always_SetsTheCurrentPlayerToThePlayerForTheItem()
        {
            var mockPlayer = new MockPlayer();
            _subject.DefaultAudioPlayer = mockPlayer;
            var playlistItem = new PlaylistItem();

            _subject.Handle(new StartPlaybackMessage(playlistItem));

            _subject.CurrentPlayer.Should().Be(mockPlayer);
        }
        public void HandleStartPlayback_Always_CallsPlayOnThePlayerForTheModelInTheMessage()
        {
            var mockPlayer = new MockPlayer();
            _subject.DefaultAudioPlayer = mockPlayer;
            var playlistItem = new PlaylistItem();

            _subject.Handle(new StartPlaybackMessage(playlistItem));

            mockPlayer.PlayCount.Should().Be(1);
            mockPlayer.PlayCallArguments.First().Should().Be(playlistItem);
        }
        private async Task <Client.Common.Models.PlaylistItem> LoadModelImpl(IId model)
        {
            Client.Common.Models.PlaylistItem playlistItem = null;
            if (model != null)
            {
                await SubsonicService.GetSong(model.Id)
                .WithErrorHandler(this)
                .OnSuccess(result => playlistItem = CreatePlaylistItemFromSong(result)).Execute();
            }

            return(playlistItem);
        }
        public static PlaylistItem AsPlaylistItem(this ISongModel songModel, ISubsonicService subsonicService)
        {
            var playlistItem = new PlaylistItem
                                   {
                                       Artist = songModel.Artist, 
                                       Title = songModel.Name, 
                                       Duration = songModel.Duration, 
                                       Uri =
                                           songModel.Type == SubsonicModelTypeEnum.Video
                                               ? subsonicService.GetUriForVideoWithId(songModel.Id)
                                               : subsonicService.GetUriForFileWithId(songModel.Id), 
                                       CoverArtUrl = subsonicService.GetCoverArtForId(songModel.CoverArt), 
                                       Type =
                                           songModel.Type == SubsonicModelTypeEnum.Video
                                               ? PlaylistItemTypeEnum.Video
                                               : PlaylistItemTypeEnum.Audio
                                   };

            return playlistItem;
        }
Exemple #6
0
 public void Play(PlaylistItem item, object options = null)
 {
     PlayCount++;
     _playCallArguments.Add(item);
 }
 public void Setup()
 {
     _subject = new PlaylistItem();
     _mockSubsonicService = new MockSubsonicService();
 }
        public void Ctor_Always_SetsCoverArtUrlToPlaceholder()
        {
            var playlistItem = new PlaylistItem();

            playlistItem.CoverArtUrl.Should().Be(SubsonicService.CoverArtPlaceholder);
        }
        public void Ctor_Always_SetsPlayingStateToNotPlaying()
        {
            var playlistItem = new PlaylistItem();

            playlistItem.PlayingState.Should().Be(PlaylistItemState.NotPlaying);
        }
 public StartVideoPlaybackMessage(PlaylistItem item)
 {
     Item = item;
     EndTime = item.Duration;
     StartTime = 0;
 }
        public void HandleWithRemoveFromPlaylistMessageShouldRemoveItemsInQueueFromCurrentPlaylist()
        {
            var playlistItem = new PlaylistItem();
            _subject.Items.Add(playlistItem);

            _subject.Handle(new RemoveItemsMessage { Queue = new List<PlaylistItem> { playlistItem } });

            _subject.Items.Should().HaveCount(0);
        }
 public PlaybackMessageBase(PlaylistItem item)
 {
     Item = item;
 }
 public void Setup()
 {
     _subject = new PlaylistItem();
 }
 public StartAudioPlaybackMessage(PlaylistItem item)
 {
     Item = item;
 }
 public void Setup()
 {
     _song = new Song
                 {
                     Artist = "testArtist", 
                     Name = "testTitle", 
                     Id = 121, 
                     CoverArt = "test123", 
                     Duration = 123, 
                     IsVideo = true
                 };
     _mockSubsonicService = new MockSubsonicService();
     _subject = _song.AsPlaylistItem(_mockSubsonicService);
 }
 public void Play(PlaylistItem item, object options = null)
 {
     Source = item.Uri;
     _playerControls.Play();
 }
 private void SetItemMetaData(PlaylistItem item)
 {
     if (item.Type == PlaylistItemTypeEnum.Audio)
     {
         _mediaTransportControls.DisplayUpdater.Type = MediaPlaybackType.Music;
         _mediaTransportControls.DisplayUpdater.MusicProperties.Artist = item.Artist;
         _mediaTransportControls.DisplayUpdater.MusicProperties.Title = item.Title;
         _mediaTransportControls.DisplayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(item.CoverArtUrl));
     }
     else
     {
         _mediaTransportControls.DisplayUpdater.Type = MediaPlaybackType.Video;
         _mediaTransportControls.DisplayUpdater.VideoProperties.Title = item.Title;
     }
     _mediaTransportControls.DisplayUpdater.Update();
 }
 public void Play(PlaylistItem item, object options = null)
 {
     throw new NotImplementedException();
 }
 public IPlayer GetPlayerFor(PlaylistItem item)
 {
     throw new NotImplementedException();
 }
 public void Play(PlaylistItem item, object options = null)
 {
     _currentItem = item;
     Source = item.Uri;
     _playerControls.Play();
     if (PlaybackStarted != null)
     {
         PlaybackStarted(this, new EventArgs());
     }
 }
 public ResumePlaybackMessage(PlaylistItem item)
     : base(item)
 {
 }
 private static int ExtractId(PlaylistItem item)
 {
     return int.Parse(item.Uri.ExtractParamterFromQuery("id"));
 }
 public StopPlaybackMessage(PlaylistItem item)
     : base(item)
 {
 }
 public PausePlaybackMessage(PlaylistItem item)
     : base(item)
 {
 }
        private Client.Common.Models.PlaylistItem CreatePlaylistItemFromSong(Song result)
        {
            var playlistItem = new Client.Common.Models.PlaylistItem();
            playlistItem.InitializeFromSong(result, SubsonicService);

            return playlistItem;
        }
 public void Play(PlaylistItem item, object options = null)
 {
 }