Ejemplo n.º 1
0
 private void OnSongChanged(SongChangeMode songChangeMode)
 {
     if (SongChanged != null)
     {
         SongChanged.Invoke(songChangeMode);
     }
 }
Ejemplo n.º 2
0
        public async Task Previous()
        {
            QueueItem nowPlaying = await GetNowPlaying();

            int i = Queue.IndexOf(nowPlaying);

            Queue[i].NowPlaying = false;
            Queue[i].Position   = 0;
            if (i == 0)
            {
                if (RepeatAll)
                {
                    Queue[Queue.Count - 1].NowPlaying = true;
                }
                else
                {
                    await Stop();
                }
            }
            else
            {
                Queue[i - 1].NowPlaying = true;
            }
            SongChanged.Invoke(this, null);
            if (PlayerState == StatePlaying)
            {
                await Play();
            }
        }
Ejemplo n.º 3
0
 private void FireSongChangeEvent()
 {
     if (SongChanged != null)
     {
         SongChanged.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Start playing a track by getting the download URL from onedrive and passing it to the native MediaPlayer
        /// </summary>
        /// <param name="track"></param>
        /// <returns></returns>
        public async Task <bool> Play(Track track, int postition = 0)
        {
            string url = await App.OneDrive.GetTrackURL(track.OneDrive_ID);

            SongChanged.Invoke(this, null);
            DependencyService.Get <PlayMusic>().Play(url, postition);
            PlayerState = StatePlaying;
            return(true);
        }
Ejemplo n.º 5
0
        public async Task <bool> Play()
        {
            QueueItem queueItem = await GetNowPlaying();

            string url = await App.OneDrive.GetTrackURL((await queueItem.GetTrack()).OneDrive_ID);

            SongChanged.Invoke(this, null);
            DependencyService.Get <PlayMusic>().Play(url, queueItem.Position);
            PlayerState = StatePlaying;
            return(true);
        }
Ejemplo n.º 6
0
        private async System.Threading.Tasks.Task HandleStationSongMetadataStage2Async(SongMetadata songMetadata)
        {
            ExtendedSongMetadata newMetadata = new ExtendedSongMetadata(songMetadata);

            bool hasMoreMetadata = await NepApp.MetadataManager.FindAdditionalMetadataAsync(newMetadata);

            CurrentSong            = newMetadata;
            CurrentSong.SongLength = newMetadata.SongLength;
            RaisePropertyChanged(nameof(CurrentSong));

            await History.AddSongAsync(CurrentSong);

            SongChanged.Invoke(this, new NepAppSongChangedEventArgs(CurrentSong));

            if (hasMoreMetadata)
            {
                ArtworkProcessor.UpdateArtworkMetadata();
            }
            else
            {
                ArtworkProcessor.ResetArtwork();
            }
        }
Ejemplo n.º 7
0
        private async void Player_StatusChanged(object sender, PlayingItemsChangedArgs e)
        {
            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async() =>
            {
                IsPlaying = player.IsPlaying;
                if (e.CurrentSong != null)
                {
                    if (!_lastSong.IsIDEqual(e.CurrentSong))
                    {
                        Song = new SongViewModel(e.CurrentSong);

                        CurrentRating = Song.Rating;

                        SongChanged?.Invoke(Song, EventArgs.Empty);

                        if (Song.Artwork != null)
                        {
                            if (lastUriPath == Song.Artwork.AbsolutePath)
                            {
                            }
                            else
                            {
                                CurrentArtwork    = Song.Artwork;
                                CurrentColorBrush = new SolidColorBrush(await ImagingHelper.GetMainColor(CurrentArtwork));
                                MainPageViewModel.Current.LeftTopColor = AdjustColorbyTheme(CurrentColorBrush);
                                lastUriPath = Song.Artwork.AbsolutePath;
                            }
                        }
                        else
                        {
                            CurrentArtwork    = null;
                            CurrentColorBrush = new SolidColorBrush(new UISettings().GetColorValue(UIColorType.Accent));
                            MainPageViewModel.Current.LeftTopColor = AdjustColorbyTheme(CurrentColorBrush);
                            lastUriPath = null;
                        }
                        if (e.Items is IList <Song> l)
                        {
                            NowListPreview = $"{e.CurrentIndex + 1}/{l.Count}";
                            NowPlayingList.Clear();
                            for (int i = 0; i < l.Count; i++)
                            {
                                NowPlayingList.Add(new SongViewModel(l[i])
                                {
                                    Index = (uint)i
                                });
                            }
                            if (e.CurrentIndex < NowPlayingList.Count)
                            {
                                CurrentIndex = e.CurrentIndex;
                            }
                        }

                        IsCurrentFavorite = await e.CurrentSong.GetFavoriteAsync();
                    }
                }
            });

            if (e.CurrentSong != null)
            {
                if (!_lastSong.IsIDEqual(e.CurrentSong))
                {
                    await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                    {
                        Lyric.Clear();
                        LyricHint = Consts.Localizer.GetString("LoadingLyricsText");
                    });

                    _lastSong = e.CurrentSong;
                    var ext = MainPageViewModel.Current.LyricExtension;
                    if (ext != null)
                    {
                        var result = await ext.ExecuteAsync(new ValueSet()
                        {
                            new KeyValuePair <string, object>("q", "lyric"),
                            new KeyValuePair <string, object>("title", Song.Title),
                            new KeyValuePair <string, object>("album", song.Album),
                            new KeyValuePair <string, object>("artist", Song.Song.Performers.IsNullorEmpty() ? null : Song.Song.Performers[0]),
                            new KeyValuePair <string, object>("ID", song.IsOnline ? song.Song.OnlineID : null)
                        });

                        if (result != null)
                        {
                            var l = new Lyric(LrcParser.Parser.Parse((string)result, Song.Song.Duration));
                            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                            {
                                Lyric.New(l);
                            });
                        }
                        else
                        {
                            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                            {
                                Lyric.Clear();
                                LyricHint = Consts.Localizer.GetString("NoLyricText");
                            });
                        }
                    }
                    else
                    {
                        await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                        {
                            Lyric.Clear();
                            LyricHint = Consts.Localizer.GetString("NoLyricText");
                        });
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public async void Init(SongViewModel song)
        {
            //Initialize our picker object
            castingPicker = new CastingDevicePicker();

            //Set the picker to filter to video capable casting devices
            castingPicker.Filter.SupportsAudio = true;

            //Hook up device selected event
            castingPicker.CastingDeviceSelected += CastingPicker_CastingDeviceSelected;

            Song      = song;
            _lastSong = new Song()
            {
                ID            = song.ID,
                IsOnline      = song.IsOnline,
                OnlineUri     = new Uri(song.FilePath),
                FilePath      = song.FilePath,
                Duration      = song.Song.Duration,
                Album         = song.Album,
                OnlineAlbumID = song.Song.OnlineAlbumID,
                OnlineID      = song.Song.OnlineID
            };
            CurrentArtwork = song.Artwork;
            lastUriPath    = song.Artwork?.AbsolutePath;
            IsPlaying      = player.IsPlaying;
            BufferProgress = MainPageViewModel.Current.BufferProgress;
            SongChanged?.Invoke(song, EventArgs.Empty);
            CurrentRating = song.Rating;
            var brush = new SolidColorBrush(await ImagingHelper.GetMainColor(CurrentArtwork));

            CurrentColorBrush = brush;
            MainPageViewModel.Current.LeftTopColor = AdjustColorbyTheme(CurrentColorBrush);
            CurrentIndex = MainPageViewModel.Current.CurrentIndex;
            var task = ThreadPool.RunAsync(async x =>
            {
                var favor = await _lastSong.GetFavoriteAsync();
                await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    IsCurrentFavorite = favor;
                });
            });

            var t = ThreadPool.RunAsync(async x =>
            {
                var ext = MainPageViewModel.Current.LyricExtension;
                if (ext != null)
                {
                    var result = await ext.ExecuteAsync(new ValueSet()
                    {
                        new KeyValuePair <string, object>("q", "lyric"),
                        new KeyValuePair <string, object>("title", Song.Title),
                        new KeyValuePair <string, object>("album", song.Album),
                        new KeyValuePair <string, object>("artist", Song.Song.Performers.IsNullorEmpty() ? null : Song.Song.Performers[0]),
                        new KeyValuePair <string, object>("ID", song.IsOnline ? song.Song.OnlineID : null)
                    });
                    if (result != null)
                    {
                        var l = new Lyric(LrcParser.Parser.Parse((string)result, Song.Song.Duration));
                        await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
                        {
                            Lyric.New(l);
                        });
                    }
                    else
                    {
                        await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
                        {
                            Lyric.Clear();
                            LyricHint = Consts.Localizer.GetString("NoLyricText");
                        });
                    }
                }
                else
                {
                    await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
                    {
                        Lyric.Clear();
                        LyricHint = Consts.Localizer.GetString("NoLyricText");
                    });
                }
            });
        }
Ejemplo n.º 9
0
 private void OnSongChanged(Song song)
 {
     SongChanged?.Invoke(this, song);
 }