Exemple #1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.CoreWindow.KeyDown += (sender, args) =>
                                                 GlobalPageKeyDown?.Invoke(sender, args);
            if (RoamingSettingsHelper.GetSetting <bool>("IsFirstTime", true))
            {
                string releaseNotes = "FIXES:\r\n\r\n" +
                                      "Fix play on tap for all touch devices.\n" +
                                      "Fixed all crashes.\r\n\r\n" +
                                      "NEW THINGS:\r\n\r\n" +
                                      "Removed enter to full screen on startup.\n" +
                                      "Removed back button from shortcuts.\n";
                await SharedLogic.NotificationManager.ShowMessageBoxAsync(releaseNotes, "What's new in v2.4.0");

                RoamingSettingsHelper.SaveSetting("IsFirstTime", false);
            }
            if (e.Parameter is StorageFile)
            {
                Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd, new List <object> {
                    e.Parameter, 0.0, true, 50.0
                });
            }

            base.OnNavigatedTo(e);
        }
        public static async Task <bool> SaveCurrentLockscreenImage()
        {
            if (RoamingSettingsHelper.GetSetting <string>("DefaultImagePath", "") != "")
            {
                DefaultImage = await StorageFile.GetFileFromPathAsync(RoamingSettingsHelper.GetSetting <string>("DefaultImagePath", ""));

                return(true);
            }
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                if (DefaultImage == null)
                {
                    bool success = false;
                    await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        MessageDialog dialog = new MessageDialog("To enable this feature you must set a default lockscreen wallpaper.\rPress OK to continue or cancel to cancel.", "Choose a default lockscreen wallpaper");
                        dialog.Commands.Add(new UICommand("OK"));
                        dialog.Commands.Add(new UICommand("Cancel"));
                        var response = await dialog.ShowAsync();
                        if (response.Label == "OK")
                        {
                            FileOpenPicker defaultLockScreenImageDialog = new FileOpenPicker()
                            {
                                CommitButtonText = "Set default lockscreen image."
                            };
                            defaultLockScreenImageDialog.FileTypeFilter.Add(".jpg");
                            defaultLockScreenImageDialog.FileTypeFilter.Add(".png");
                            var image = await defaultLockScreenImageDialog.PickSingleFileAsync();
                            if (image != null)
                            {
                                DefaultImage = await image.CopyAsync(ApplicationData.Current.LocalFolder, "lockscreen.jpg", NameCollisionOption.ReplaceExisting);
                                RoamingSettingsHelper.SaveSetting("DefaultImagePath", DefaultImage.Path);
                                success = true;
                            }
                        }
                    });

                    return(success);
                }
            }
            else if (!File.Exists(ApplicationData.Current.TemporaryFolder.Path + "\\lockscreen.jpg"))
            {
                using (IRandomAccessStream imageStream = LockScreen.GetImageStream())
                    using (var reader = new DataReader(imageStream))
                    {
                        var lockscreenFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("lockscreen.jpg", CreationCollisionOption.FailIfExists);

                        await reader.LoadAsync((uint)imageStream.Size);

                        var buffer = new byte[(int)imageStream.Size];
                        reader.ReadBytes(buffer);
                        await FileIO.WriteBytesAsync(lockscreenFile, buffer);

                        DefaultImage = lockscreenFile;
                        StorageApplicationPermissions.FutureAccessList.Add(DefaultImage);
                    }
                return(true);
            }
            return(false);
        }
        public static async void LoadSettings(bool onlyVol = false, bool play = false)
        {
            var volume = RoamingSettingsHelper.GetSetting <double>(VolKey, 50.0);

            if (!onlyVol)
            {
                _path = RoamingSettingsHelper.GetSetting <string>(PathKey, "");
                string folders = RoamingSettingsHelper.GetSetting <string>(FoldersKey, "");
                folders.Split('|').ToList().ForEach(async str =>
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        var folder = await StorageFolder.GetFolderFromPathAsync(str);
                        SharedLogic.SettingsVm.LibraryFoldersCollection.Add(folder);
                    }
                });
                // SettingsVM.LibraryFoldersCollection.ToList().ForEach(new Action<StorageFolder>((StorageFolder folder) => { folderPaths += folder.Path + "|"; }));
                if (_path != "" && SharedLogic.VerifyFileExists(_path, 300))
                {
                    double position = RoamingSettingsHelper.GetSetting <double>(PosKey, 0);
                    SharedLogic.Player.PlayerState = PlayerState.Paused;
                    try
                    {
                        Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd,
                                                            new List <object> {
                            await StorageFile.GetFileFromPathAsync(_path), position, play, volume
                        });
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        BLogger.Logger.Error("Access denied while trying to play file on startup.", ex);
                    }
                }
            }
        }
Exemple #4
0
        private async void LibraryViewModel_MusicLibraryLoaded(object sender, RoutedEventArgs e)
        {
            if (!libraryLoaded)
            {
                libraryLoaded = true;
                if (TracksCollection.Elements.Any(t => t.State == PlayerState.Playing))
                {
                    var sa = TracksCollection.Elements.Where(l => l.State == PlayerState.Playing);
                    foreach (var mp3 in sa)
                    {
                        mp3.State = PlayerState.Stopped;
                    }
                }
                string path = RoamingSettingsHelper.GetSetting <string>("path", "");
                if (TracksCollection.Elements.Any(t => t.Path == path))
                {
                    TracksCollection.Elements.FirstOrDefault(t => t.Path == path).State = PlayerState.Playing;
                }
                await CreateGenreMenu().ConfigureAwait(false);

                BLogger.Logger.Info("Library successfully loaded!");
                await NotificationManager.ShowMessageAsync("Library successfully loaded!");

                await Task.Delay(10000);

                Common.DirectoryWalker.SetupDirectoryWatcher(SettingsVM.LibraryFoldersCollection);
            }
        }
Exemple #5
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.CoreWindow.KeyDown += (sender, args) =>
                                                 GlobalPageKeyDown?.Invoke(sender, args);
            if (RoamingSettingsHelper.GetSetting <bool>("IsFirstTime", true))
            {
                string releaseNotes = "𝐖𝐡𝐚𝐭'𝐬 𝐅𝐢𝐱𝐞𝐝:\n\n" +
                                      "• Fixed issue where library import took too much time.\n" +
                                      "• Fixed issue where many album arts were not loaded.\n" +
                                      "• Fixed other bugs.\n\n" +
                                      "𝐖𝐡𝐚𝐭'𝐬 𝐍𝐞𝐰:\n\n" +
                                      "• Added ability to ignore DRM-Protected songs. (𝑒𝑥𝑝𝑟𝑖𝑚𝑒𝑛𝑡𝑎𝑙)\n" +
                                      "• Added sorting by tracknumber for album songs.\n";
                await SharedLogic.NotificationManager.ShowMessageBoxAsync(releaseNotes, "What's new in v2.6.2");

                RoamingSettingsHelper.SaveSetting("IsFirstTime", false);
            }
            if (e.Parameter is StorageFile)
            {
                Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd, new List <object> {
                    e.Parameter, 0.0, true, 50.0
                });
            }

            base.OnNavigatedTo(e);
        }
Exemple #6
0
        private void InitializeTheme()
        {
            var value = RoamingSettingsHelper.GetSetting <string>("SelectedTheme", "Light");
            var theme = Enum.Parse(typeof(ApplicationTheme), value);

            RequestedTheme = (ApplicationTheme)theme;
        }
Exemple #7
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.CoreWindow.KeyDown += (sender, args) =>
                                                 GlobalPageKeyDown?.Invoke(sender, args);
            if (RoamingSettingsHelper.GetSetting <bool>("IsFirstTime", true))
            {
                string releaseNotes = "FIXES:\r\n\r\n" +
                                      "We fixed the startup crash.\n" +
                                      "Fixed crash when changing theme.\n" +
                                      "Fixed crash when play songs from an album.\n" +
                                      "Fixed other various bugs and crashes.\r\n\r\n" +
                                      "NEW THINGS:\r\n\r\n" +
                                      "Added 'Now Playing' Screen with artist and album info fetching.\r\n\r\n" +
                                      "IMPROVEMENTS:\r\n\r\n" +
                                      "Greatly improved performance and navigation.\n" +
                                      "Improved Equalizer UI.\nImproved Blur\n" +
                                      "Improved UI (less glitches etc.)\r\n";
                await SharedLogic.NotificationManager.ShowMessageBoxAsync(releaseNotes, "What's new in v2.3.0");

                RoamingSettingsHelper.SaveSetting("IsFirstTime", false);
            }
            if (e.Parameter is StorageFile)
            {
                Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd, new List <object> {
                    e.Parameter, 0.0, true, 50.0
                });
            }

            base.OnNavigatedTo(e);
        }
Exemple #8
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.CoreWindow.KeyDown += (sender, args) =>
                                                 GlobalPageKeyDown?.Invoke(sender, args);
            if (RoamingSettingsHelper.GetSetting <bool>("IsFirstTime", true))
            {
                string releaseNotes = "FIXES:\r\n\r\n" +
                                      "Fixed 2 random crashes.\n" +
                                      "Fixed invisible jumplist issue when in sort/grouped mode.\n" +
                                      "Fixed empty album issue.\n" +
                                      "Fixed issue with auto loading of library at startup.\n" +
                                      "Fixed issue where song wasn't played from external speakers/headphones.\n" +
                                      "NEW THINGS:\r\n\r\n" +
                                      "Added support for German Translation (thanks to Armin).\n" +
                                      "Added backward navigation support for mobiles.\n" +
                                      "IMPROVEMENTS:\r\n\r\n" +
                                      "Core improvements (shuffle and other things).\n" +
                                      "Icon was improved.\n";
                await SharedLogic.NotificationManager.ShowMessageBoxAsync(releaseNotes, "What's new in v2.6.0");

                RoamingSettingsHelper.SaveSetting("IsFirstTime", false);
            }
            if (e.Parameter is StorageFile)
            {
                Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd, new List <object> {
                    e.Parameter, 0.0, true, 50.0
                });
            }

            base.OnNavigatedTo(e);
        }
Exemple #9
0
        private async void HandleExecuteCmdMessage(Message message)
        {
            if (message.Payload == null)
            {
                return;
            }

            if (message.Payload is List <object> list)
            {
                double volume = 0;
                if ((double)list[3] == 50.0)
                {
                    volume = RoamingSettingsHelper.GetSetting <double>("volume", 50.0);
                }
                else
                {
                    volume = (double)list[3];
                }

                await Load(await SharedLogic.CreateMediafile(list[0] as StorageFile), (bool)list[2], (double)list[1], volume);
            }
            else
            {
                GetType().GetTypeInfo().GetDeclaredMethod(message.Payload as string)?.Invoke(this, new object[] { });
            }

            message.HandledStatus = MessageHandledStatus.HandledCompleted;
        }
 void HandleExecuteCmdMessage(Message message)
 {
     if (message.Payload != null)
     {
         if (message.Payload is List <object> )
         {
             var    list   = message.Payload as List <object>;
             double volume = 0;
             if ((double)list[3] == 50.0)
             {
                 volume = RoamingSettingsHelper.GetSetting <double>("volume", 50.0);
             }
             else
             {
                 volume = (double)list[3];
             }
             Play(list[0] as StorageFile, null, (double)list[1], (bool)list[2], volume);
         }
         else
         {
             this.GetType().GetTypeInfo().GetDeclaredMethod(message.Payload as string)?.Invoke(this, new object[] { });
         }
         message.HandledStatus = MessageHandledStatus.HandledCompleted;
     }
 }
 public SettingsViewModel()
 {
     IsPlaybarOnBottom      = RoamingSettingsHelper.GetSetting <bool>("IsPlaybarOnBottom", false);
     ChangeAccentByAlbumArt = RoamingSettingsHelper.GetSetting <bool>("ChangeAccentByAlbumArt", true);
     FileBatchSize          = RoamingSettingsHelper.GetSetting <int>("FileBatchSize", 100);
     TimeOpened             = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss");
     Messengers.Messenger.Instance.Register(Messengers.MessageTypes.MSG_LIBRARY_LOADED, new Action <Message>(HandleLibraryLoadedMessage));
 }
Exemple #12
0
        /// <summary>
        /// Adds modified files got from querying in the <see cref="LibraryFoldersCollection"/>. The query parameters include time range from <see cref="TimeClosed"/> to <seealso cref="TimeOpened"/>.
        /// </summary>
        private async Task AddModifiedFilesAsync()
        {
            TimeClosed    = RoamingSettingsHelper.GetSetting <string>("timeclosed", "0");
            ModifiedFiles = await Common.DirectoryWalker.GetModifiedFiles(LibraryFoldersCollection, TimeClosed);

            if (ModifiedFiles.Any())
            {
                RenameAddOrDeleteFiles(ModifiedFiles);
            }
        }
Exemple #13
0
        public CoreWindowLogic()
        {
            if (StorageApplicationPermissions.FutureAccessList.Entries.Count >= 999)
            {
                StorageApplicationPermissions.FutureAccessList.Clear();
            }
            InitSmtc();
            var volume = RoamingSettingsHelper.GetSetting <double>(volKey, 50.0);

            Player.Volume = volume;
        }
        public CoreWindowLogic()
        {
            if (StorageApplicationPermissions.FutureAccessList.Entries.Count >= 999)
            {
                StorageApplicationPermissions.FutureAccessList.Clear();
            }

            InitSmtc();
            SharedLogic.Player.Volume   = RoamingSettingsHelper.GetSetting <double>(VolKey, 50.0);
            Window.Current.SizeChanged += Current_SizeChanged;
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.CoreWindow.KeyDown += (sender, args) =>
                                                 GlobalPageKeyDown?.Invoke(sender, args);
            if (RoamingSettingsHelper.GetSetting <bool>("IsFirstTime", true))
            {
                string releaseNotes = "FIXES:\r\n\r\n" +
                                      "Fixed issue with output device not changing when headphones are connected.\n" +
                                      "Fixed NowPlayingList loses its ItemTemplate when window size is changed.\n" +
                                      "Fixed crash after library load.\n" +
                                      "Fixed playlist import.\n" +
                                      "Fixed audio stutter when minimizing to background (only mobile).\n" +
                                      "Fixed crash when deleting duplicates.\r\n\r\n" +
                                      "NEW THINGS:\r\n\r\n" +
                                      "Added new Keyboard Shortcuts ('Keybindings' section in Settings).\n" +
                                      "Added full translation support.\n" +
                                      "Added ability to export playlist (only to .m3u & .pls for now).\n" +
                                      "Added silent upcoming song notifications.\n" +
                                      "Added translations for Czech and Sinhala languages.\n" +
                                      "Added equalizer presets (experimental).\n" +
                                      "Added real-time music library updates when filesystem changes (only works when app is running).\n" +
                                      "Added 'Contribute' section in settings to help in contributing.\n" +
                                      "Added auto playback stop in BreadPlayer when a song is played in Groove Player.\n" +
                                      "Added navigate to now playing screen when song is played on mobile.\n" +
                                      "Added auto removal of duplicates when importing songs.\n" +
                                      "Added navigate to now playing screen when song's tags are clicked in mini player.\r\n\r\n" +
                                      "IMPROVEMENTS:\r\n\r\n" +
                                      "Improved hamburger menu list item response on tap/click.\n" +
                                      "Improved all animations and transitions.\n" +
                                      "Improved navigation performance.\n" +
                                      "Improved library import.\n" +
                                      "Improved overall UI and increased readability.\n" +
                                      "Improved startup performance by 50% (only PC).\r\n";
                await SharedLogic.NotificationManager.ShowMessageBoxAsync(releaseNotes, "What's new in v2.3.0 (after 120+ commits)");

                RoamingSettingsHelper.SaveSetting("IsFirstTime", false);
            }
            if (e.Parameter is StorageFile)
            {
                Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd, new List <object> {
                    e.Parameter, 0.0, true, 50.0
                });
            }

            base.OnNavigatedTo(e);
        }
Exemple #16
0
        public async Task LoadFolders()
        {
            if (LibraryFoldersCollection.Count <= 0)
            {
                var folderPaths = RoamingSettingsHelper.GetSetting <string>("folders", null);
                if (folderPaths != null)
                {
                    foreach (var folder in folderPaths.Split('|'))
                    {
                        if (!string.IsNullOrEmpty(folder))
                        {
                            var storageFolder = await StorageFolder.GetFolderFromPathAsync(folder);

                            LibraryFoldersCollection.Add(storageFolder);
                        }
                    }
                }
            }
        }
Exemple #17
0
        public static async void SetThemeColor(string albumartPath)
        {
            await BreadDispatcher.InvokeAsync(async() =>
            {
                if (SharedLogic.SettingsVm.ChangeAccentByAlbumArt == false)
                {
                    ChangeColor(GetAccentColor());
                    return;
                }
                if (RoamingSettingsHelper.GetSetting <string>("SelectedTheme", "Light") == "Light" && SharedLogic.SettingsVm.ChangeAccentByAlbumArt)
                {
                    try
                    {
                        Color color;
                        if (!string.IsNullOrEmpty(albumartPath) && albumartPath != "default")
                        {
                            color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(albumartPath));
                        }
                        else if (albumartPath == "default" && SharedLogic.Player.CurrentlyPlayingFile != null)
                        {
                            color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(SharedLogic.Player.CurrentlyPlayingFile.AttachedPicture));
                        }
                        else
                        {
                            color = GetAccentColor();
                        }

                        ChangeColor(color);
                    }
                    catch (Exception ex)
                    {
                        BLogger.Logger.Error("Failed to update accent.", ex);
                        await SharedLogic.NotificationManager.ShowMessageAsync(ex.Message);
                    }
                    //ThemeChanged?.Invoke(null, new Events.ThemeChangedEventArgs(oldColor, color));
                }
                else
                {
                    ChangeColor(GetAccentColor());
                }
            });
        }
Exemple #18
0
        private void SetNowPlayingSong()
        {
            string path = RoamingSettingsHelper.GetSetting <string>("path", "");

            if (!TracksCollection.Elements.Any(t => t.Path == path && t.State == PlayerState.Playing))
            {
                if (TracksCollection.Elements.Any(t => t.State == PlayerState.Playing))
                {
                    var sa = TracksCollection.Elements.Where(l => l.State == PlayerState.Playing);
                    foreach (var mp3 in sa)
                    {
                        mp3.State = PlayerState.Stopped;
                    }
                }
                if (TracksCollection.Elements.Any(t => t.Path == path))
                {
                    TracksCollection.Elements.FirstOrDefault(t => t.Path == path).State = PlayerState.Playing;
                }
            }
        }
Exemple #19
0
        public static async void Replay(bool onlyVol = false)
        {
            try
            {
                SettingsVM.TimeClosed = RoamingSettingsHelper.GetSetting <string>(timeclosedKey, "0");
                var volume = RoamingSettingsHelper.GetSetting <double>(volKey, 50);
                if (onlyVol)
                {
                    Player.Volume = volume;
                }
                else
                {
                    path = RoamingSettingsHelper.GetSetting <string>(pathKey, "");
                    if (path != "")
                    {
                        double position = RoamingSettingsHelper.GetSetting <double>(posKey, 0);
                        Player.PlayerState = PlayerState.Paused;
                        try
                        {
                            Messengers.Messenger.Instance.NotifyColleagues(Messengers.MessageTypes.MSG_EXECUTE_CMD, new List <object> {
                                await StorageFile.GetFileFromPathAsync(path), position, false, volume
                            });

                            //ShellVM.Play(await StorageFile.GetFileFromPathAsync(path), null, position, false, volume);
                        }
                        catch (UnauthorizedAccessException) { }
                    }
                }

                //var folderPaths = RoamingSettingsHelper.GetSetting<ThreadSafeObservableCollection<StorageFolder>>(foldersKey, null);
                //if (folderPaths != null)
                //{
                //    SettingsVM.LibraryFoldersCollection = folderPaths;
                //}
            }
            catch { }
        }
Exemple #20
0
        public static async void LoadSettings(bool onlyVol = false, bool play = false)
        {
            var volume = RoamingSettingsHelper.GetSetting <double>(volKey, 50.0);

            if (!onlyVol)
            {
                path = RoamingSettingsHelper.GetSetting <string>(pathKey, "");
                if (path != "" && VerifyFileExists(path, 300))
                {
                    double position = RoamingSettingsHelper.GetSetting <double>(posKey, 0);
                    Player.PlayerState = PlayerState.Paused;
                    try
                    {
                        Messengers.Messenger.Instance.NotifyColleagues(Messengers.MessageTypes.MSG_EXECUTE_CMD, new List <object> {
                            await StorageFile.GetFileFromPathAsync(path), position, play, volume
                        });
                    }
                    catch (UnauthorizedAccessException) { }
                }
            }

            var folderPaths = RoamingSettingsHelper.GetSetting <string>(foldersKey, null);

            if (folderPaths != null)
            {
                foreach (var folder in folderPaths.Split('|'))
                {
                    if (!string.IsNullOrEmpty(folder))
                    {
                        var storageFolder = await StorageFolder.GetFolderFromPathAsync(folder);

                        SettingsVM.LibraryFoldersCollection.Add(storageFolder);
                    }
                }
            }
        }
Exemple #21
0
        public static async void LoadSettings(bool onlyVol = false, bool play = false)
        {
            var volume = RoamingSettingsHelper.GetSetting <double>(volKey, 50.0);

            if (!onlyVol)
            {
                path = RoamingSettingsHelper.GetSetting <string>(pathKey, "");
                if (path != "" && VerifyFileExists(path, 300))
                {
                    double position = RoamingSettingsHelper.GetSetting <double>(posKey, 0);
                    Player.PlayerState = PlayerState.Paused;
                    try
                    {
                        Messengers.Messenger.Instance.NotifyColleagues(Messengers.MessageTypes.MSG_EXECUTE_CMD, new List <object> {
                            await StorageFile.GetFileFromPathAsync(path), position, play, volume
                        });
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        BLogger.Logger.Error("Access denied while trying to play file on startup.", ex);
                    }
                }
            }
        }
Exemple #22
0
 private void GetSettings()
 {
     Sort = RoamingSettingsHelper.GetSetting <string>("Sort", "Unsorted");
 }
 private void GetSettings()
 {
     Shuffle          = RoamingSettingsHelper.GetSetting <bool>("Shuffle", false);
     IsPlayBarVisible = RoamingSettingsHelper.GetSetting <bool>("IsPlayBarVisible", true);
     Repeat           = RoamingSettingsHelper.GetSetting <string>("Repeat", "No Repeat");
 }