diff --git a/Mear/Mear/Playback/MearPlayer.cs b/Mear/Mear/Playback/MearPlayer.cs index 3514c2d..cca4897 100644 --- a/Mear/Mear/Playback/MearPlayer.cs +++ b/Mear/Mear/Playback/MearPlayer.cs @@ -18,7 +18,8 @@ namespace Mear.Playback { public class MearPlayer { - #region Fields + #region Fields + private static Song _song; #endregion @@ -100,7 +101,9 @@ namespace Mear.Playback return StreamSong(song); break; case PlayControls.REPEAT: - // TODO: Implement repeat + // TODO: Not fully implemented + CrossMediaManager.Current.ToggleRepeat(); + var i = CrossMediaManager.Current.RepeatMode; break; case PlayControls.SHUFFLE: // TODO: Implement shuffling diff --git a/Mear/Mear/Repositories/Database/DBMusicControls.cs b/Mear/Mear/Repositories/Database/DBMusicControls.cs deleted file mode 100644 index 9b41b6c..0000000 --- a/Mear/Mear/Repositories/Database/DBMusicControls.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using Mear.Models; - -namespace Mear.Repositories.Database -{ - // TODO: Implement the database functionality #35 - public class DBMusicControls : DBRepository - { - #region Fields - #endregion - - - #region Properties - #endregion - - - #region Constructors - public DBMusicControls() - { - Initialize(); - } - #endregion - - - #region Methods - public bool IsShuffleOn() - { - try - { - if (DoesTableExist("MusicControls")) - { - bool? shuffle = _Db.Table().First().ShuffleOn; - - if (shuffle != null) - { - return shuffle.Value; ; - } - } - } - catch (Exception ex) - { - var msg = ex.Message; - } - - return false; - } - public bool IsRepeatOn() - { - try - { - if (DoesTableExist("MusicControls")) - { - bool? repeat = _Db.Table().First().RepeatOn; - - if (repeat != null) - { - return repeat.Value; - } - } - } - catch (Exception ex) - { - var msg = ex.Message; - } - - return false; - } - #endregion - } -} diff --git a/Mear/Mear/Repositories/Database/DBMusicControlsRepository.cs b/Mear/Mear/Repositories/Database/DBMusicControlsRepository.cs new file mode 100644 index 0000000..e278381 --- /dev/null +++ b/Mear/Mear/Repositories/Database/DBMusicControlsRepository.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Mear.Models; + +namespace Mear.Repositories.Database +{ + // TODO: Implement the database functionality #35 + public class DBMusicControlsRepository : DBRepository + { + #region Fields + #endregion + + + #region Properties + #endregion + + + #region Constructors + public DBMusicControlsRepository() + { + Initialize(); + InitializeTable(); + } + #endregion + + + #region Methods + public bool IsShuffleOn() + { + try + { + if (DoesTableExist("MusicControls")) + { + bool? shuffle = _Db.Table().First().ShuffleOn; + + if (shuffle != null) + { + return shuffle.Value; ; + } + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + + return false; + } + public bool IsRepeatOn() + { + try + { + if (DoesTableExist("MusicControls")) + { + bool? repeat = _Db.Table().First().RepeatOn; + + if (repeat != null) + { + return repeat.Value; + } + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + + return false; + } + + public void UpdateRepeat() + { + try + { + if (DoesTableExist("MusicControls")) + { + var control = RetrieveMusicControls(); + control.RepeatOn = !control.RepeatOn; + _Db.Update(control); + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + } + public void UpdateShuffle() + { + try + { + if (DoesTableExist("MusicControls")) + { + var control = RetrieveMusicControls(); + control.ShuffleOn = (!control.ShuffleOn); + + _Db.Update(control); + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + } + + private MusicControls RetrieveMusicControls() + { + try + { + var controls = _Db.Table().First(); + + return controls; + } + catch (Exception ex) + { + var msg = ex.Message; + } + + return null; + } + private void InitializeTable() + { + try + { + if (!DoesTableExist("MusicControls")) + { + _Db.CreateTable(); + } + + var controls = RetrieveMusicControls(); + + if (controls == null) + { + var initControl = new MusicControls(); + _Db.Insert(initControl); + } + } + catch (Exception ex) + { + var msg = ex.Message; + } + } + #endregion + } +} diff --git a/Mear/Mear/Views/MearPlayerView.xaml b/Mear/Mear/Views/MearPlayerView.xaml index 1f757ad..ab09694 100644 --- a/Mear/Mear/Views/MearPlayerView.xaml +++ b/Mear/Mear/Views/MearPlayerView.xaml @@ -33,10 +33,10 @@