Exemplo n.º 1
0
        public override async void Execute(object parameter)
        {
            if (parameter is AlbumItem)
            {
                var album = parameter as AlbumItem;
                album.IsPinned = !album.IsPinned;
                await Locator.MusicLibraryVM._albumDatabase.Update(album);

                UpdateTileHelper.CreateOrReplaceSecondaryTile(VLCItemType.Album, album.Id, album.Name);
            }
        }
Exemplo n.º 2
0
        public override async void Execute(object parameter)
        {
            if (parameter is ArtistItem)
            {
                var artist = parameter as ArtistItem;
                artist.IsPinned = !artist.IsPinned;
                await Locator.MusicLibraryVM._artistDatabase.Update(artist);

                UpdateTileHelper.CreateOrReplaceSecondaryTile(VLCItemType.Artist, artist.Id, artist.Name);
            }
        }
Exemplo n.º 3
0
 public async Task UpdatePlayingUI()
 {
     await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         Locator.MediaPlaybackViewModel.TrackCollection.IsRunning = true;
         Locator.MediaPlaybackViewModel.TrackCollection.SetActiveTrackProperty();
         OnPropertyChanged("TrackCollection");
         OnPropertyChanged("PlayingType");
         OnPropertyChanged("CurrentTrack");
         UpdateTileHelper.UpdateMediumTileWithMusicInfo();
     });
 }
        public async Task PlayPrevious()
        {
            if (TrackCollection.CanGoPrevious)
            {
                await DispatchHelper.InvokeAsync(() => TrackCollection.CurrentTrack--);

                await Locator.MediaPlaybackViewModel.SetMedia(CurrentMedia, false);
            }
            else
            {
                UpdateTileHelper.ClearTile();
            }
        }
 public async Task PlayNext()
 {
     if (TrackCollection.CanGoNext)
     {
         await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
         {
             TrackCollection.CurrentTrack++;
             await Locator.MediaPlaybackViewModel.SetMedia(CurrentMedia, false);
         });
     }
     else
     {
         UpdateTileHelper.ClearTile();
     }
 }
Exemplo n.º 6
0
        public void SetActiveMusicInfo(string token, MusicLibraryViewModel.TrackItem track)
        {
            _fileToken = token;
            _mrl       = "file://" + token;
            Title      = track.Name;
            Artist     = Locator.MusicLibraryVM.Artist.FirstOrDefault(x => x.Name == track.ArtistName);
            if (Artist != null)
            {
                Artist.CurrentAlbumIndex = _artist.Albums.IndexOf(_artist.Albums.FirstOrDefault(x => x.Name == track.AlbumName));
            }
            _mediaService.SetMediaFile(_mrl, isAudioMedia: true);
            OnPropertyChanged("TimeTotal");
#if NETFX_CORE
            UpdateTileHelper.UpdateMediumTileWithMusicInfo();
#endif
            _mediaService.Play();
        }
        public async Task UpdateTileAsync(ObservableCollection <ToDo> todos)
        {
            try
            {
                this.Opacity = 1;

                if (!AppSettings.Instance.EnableTile)
                {
                    UpdateTileHelper.ClearAllSchedules();
                    return;
                }

                await InnerUpdateTile(todos);
            }
            catch (Exception e)
            {
                var task = Logger.LogAsync(e);
            }
            finally
            {
                this.Opacity = 0;
            }
        }
Exemplo n.º 8
0
        public LiveTileTemplate()
        {
            this.InitializeComponent();

            Messenger.Default.Register <GenericMessage <ObservableCollection <ToDo> > >(this, MessengerTokens.UpdateTile, async schedules =>
            {
                if (LocalSettingHelper.GetValue("EnableTile") == "false")
                {
                    UpdateTileHelper.ClearAllSchedules();
                    return;
                }

                //if (LocalSettingHelper.GetValue("EnableBackgroundTask") == "true")
                //{
                //    UpdateNormalTile(schedules.Content);
                //}
                //else
                //{
                //    await UpdateCustomeTile(schedules.Content);
                //}

                await UpdateCustomeTile(schedules.Content);
            });
        }
        public async Task SetMedia(IVLCMedia media, bool forceVlcLib = false, bool autoPlay = true)
        {
            if (media == null)
            {
                throw new ArgumentNullException("media", "Media parameter is missing. Can't play anything");
            }
            Stop();
            UseVlcLib = true; // forceVlcLib;

            if (media is VideoItem)
            {
                await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    PlayingType = PlayingType.Video;
                    IsStream    = false;
                    Locator.NavigationService.Go(VLCPage.VideoPlayerPage);
                });

                var video = (VideoItem)media;
                await Locator.MediaPlaybackViewModel.InitializePlayback(video, autoPlay);

                if (video.TimeWatched != TimeSpan.FromSeconds(0))
                {
                    await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Locator.MediaPlaybackViewModel.Time = (Int64)video.TimeWatched.TotalMilliseconds);
                }

                await SetMediaTransportControlsInfo(string.IsNullOrEmpty(video.Name)? "Video" : video.Name);

                UpdateTileHelper.UpdateMediumTileWithVideoInfo();
            }
            else if (media is TrackItem)
            {
                await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    IsStream    = false;
                    PlayingType = PlayingType.Music;
                });

                var         track = (TrackItem)media;
                StorageFile currentTrackFile;
                try
                {
                    currentTrackFile = track.File ?? await StorageFile.GetFileFromPathAsync(track.Path);
                }
                catch (Exception exception)
                {
                    await MusicLibraryManagement.RemoveTrackFromCollectionAndDatabase(track);

                    await Task.Delay(500);

                    if (TrackCollection.CanGoNext)
                    {
                        await PlayNext();
                    }
                    else
                    {
                        await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => Locator.NavigationService.GoBack_Specific());
                    }
                    return;
                }
                await Locator.MediaPlaybackViewModel.InitializePlayback(track, autoPlay);

                if (_playerEngine != PlayerEngine.BackgroundMFPlayer)
                {
                    await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        await Locator.MusicPlayerVM.SetCurrentArtist();
                        await Locator.MusicPlayerVM.SetCurrentAlbum();
                        await Locator.MusicPlayerVM.UpdatePlayingUI();
                        Locator.Slideshow.AddImg(Locator.MusicPlayerVM.CurrentArtist.Picture);
#if WINDOWS_APP
                        await Locator.MusicPlayerVM.UpdateWindows8UI();
                        await Locator.MusicPlayerVM.Scrobble();
#endif
                    });
                }
                ApplicationSettingsHelper.SaveSettingsValue(BackgroundAudioConstants.CurrentTrack, TrackCollection.CurrentTrack);
            }
            else if (media is StreamMedia)
            {
                UseVlcLib = true;
                await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    Locator.VideoVm.CurrentVideo = null;
                    Locator.MediaPlaybackViewModel.PlayingType = PlayingType.Video;
                    IsStream = true;
                });

                await Locator.MediaPlaybackViewModel.InitializePlayback(media, autoPlay);
            }
        }
        private async Task InnerUpdateTile(ObservableCollection <ToDo> schedules)
        {
            try
            {
                //关闭了磁贴更新
                if (!AppSettings.Instance.EnableTile)
                {
                    UpdateTileHelper.ClearAllSchedules();
                    return;
                }

                CleanUpTileTemplate();

                LargeBackGrd.Background      = WideBackGrd.Background =
                    MiddleBackGrd.Background = SmallBackGrd.Background = new SolidColorBrush(Colors.Transparent);

                List <string> undoList = new List <string>();

                foreach (var sche in schedules)
                {
                    if (!sche.IsDone)
                    {
                        undoList.Add(sche.Content);
                    }
                }

                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();

                LargeText0.Text = WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(0) ?? "";
                LargeText1.Text = WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(1) ?? "";
                LargeText2.Text = WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(2) ?? "";
                LargeText3.Text = WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(3) ?? "";

                LargeText4.Text = undoList.ElementAtOrDefault(4) ?? "";
                LargeText5.Text = undoList.ElementAtOrDefault(5) ?? "";
                LargeText6.Text = undoList.ElementAtOrDefault(6) ?? "";
                LargeText7.Text = undoList.ElementAtOrDefault(7) ?? "";
                LargeText8.Text = undoList.ElementAtOrDefault(8) ?? "";

                LargeCount.Text = WideCount.Text = MiddleCount.Text = SmallCount.Text = undoList.Count.ToString();

                if (undoList.Count == 0)
                {
                    LargeText0.Text = WideText0.Text = MiddleText0.Text = "Enjoy your day ;-)";
                }

                UpdateTileHelper.ClearAllSchedules();

                //少于4个待办事项,不轮播
                if (undoList.Count <= 4)
                {
                    await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, true, false);
                }
                else
                {
                    //把前4条插入轮播
                    await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, true, true);

                    if (undoList.Count > 4)
                    {
                        WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(4) ?? "";
                        WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(5) ?? "";
                        WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(6) ?? "";
                        WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(7) ?? "";

                        //把5~8条加入轮播
                        await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, false, true);
                    }
                    if (undoList.Count > 8)
                    {
                        WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(8) ?? "";
                        WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(9) ?? "";
                        WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(10) ?? "";
                        WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(11) ?? "";

                        //大于8的加入轮播
                        await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, false, true);
                    }
                }
            }
            catch (Exception e)
            {
                var task = Logger.LogAsync(e);
            }
        }
Exemplo n.º 11
0
        public async Task UpdateCustomeTile(ObservableCollection <ToDo> schedules)
        {
            try
            {
                if (LocalSettingHelper.GetValue("EnableTile") == "false")
                {
                    UpdateTileHelper.ClearAllSchedules();
                    return;
                }

                CleanUpTileTemplate();

                if (LocalSettingHelper.GetValue("TransparentTile") == "true")
                {
                    backgrd1.Background = backgrd2.Background = backgrd3.Background = new SolidColorBrush(Colors.Transparent);
                }


                List <string> undoList = new List <string>();

                foreach (var sche in schedules)
                {
                    if (!sche.IsDone)
                    {
                        undoList.Add(sche.Content);
                    }
                }

                Text0.Text = Text00.Text = undoList.ElementAtOrDefault(0) ?? "";
                Text1.Text = Text01.Text = undoList.ElementAtOrDefault(1) ?? "";
                Text2.Text = Text02.Text = undoList.ElementAtOrDefault(2) ?? "";
                Text3.Text = Text03.Text = undoList.ElementAtOrDefault(3) ?? "";

                Count1.Text = Count2.Text = Count3.Text = undoList.Count.ToString();

                if (undoList.Count == 0)
                {
                    Text0.Text = Text00.Text = "Enjoy your day ;-)";
                }

                UpdateTileHelper.ClearAllSchedules();

                if (undoList.Count <= 4)
                {
                    await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, false);
                }
                else
                {
                    await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true);

                    if (undoList.Count > 4)
                    {
                        Text0.Text = Text00.Text = undoList.ElementAtOrDefault(4) ?? "";
                        Text1.Text = Text01.Text = undoList.ElementAtOrDefault(5) ?? "";
                        Text2.Text = Text02.Text = undoList.ElementAtOrDefault(6) ?? "";
                        Text3.Text = Text03.Text = undoList.ElementAtOrDefault(7) ?? "";
                        await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true);
                    }
                    if (undoList.Count > 8)
                    {
                        Text0.Text = Text00.Text = undoList.ElementAtOrDefault(8) ?? "";
                        Text1.Text = Text01.Text = undoList.ElementAtOrDefault(9) ?? "";
                        Text2.Text = Text02.Text = undoList.ElementAtOrDefault(10) ?? "";
                        Text3.Text = Text03.Text = undoList.ElementAtOrDefault(11) ?? "";
                        await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true);
                    }
                }
            }
            catch (Exception e)
            {
                var task = ExceptionHelper.WriteRecord(e);
            }
        }