Added Song DB repository but functionality is not fully implemented. Working on the song player view.
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
<EmbeddedResource Update="Views\LoginPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Views\MearPlayerView.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Views\MusicLibrary.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using SQLite;
|
||||
|
||||
namespace Mear.Models
|
||||
{
|
||||
[DataContract]
|
||||
[Table("Song")]
|
||||
public class Song
|
||||
{
|
||||
[PrimaryKey, Column("Id"), AutoIncrement]
|
||||
[JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
[JsonProperty("title")]
|
||||
@@ -24,7 +29,7 @@ namespace Mear.Models
|
||||
public int? Duration { get; set; }
|
||||
[JsonProperty("filename")]
|
||||
public string Filename { get; set; }
|
||||
[JsonProperty("song_path")]
|
||||
[JsonIgnore]
|
||||
public string SongPath { set; get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace Mear.Playback
|
||||
var response = client.DownloadData(request);
|
||||
|
||||
await CrossMediaManager.Current.Play(tmpFile);
|
||||
var title = CrossMediaManager.Current.MediaQueue.Title;
|
||||
var title = CrossMediaManager.Current.MediaQueue.Current.Title;
|
||||
var ttl = CrossMediaManager.Current.MediaQueue.Title;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using SQLite;
|
||||
|
||||
using Mear.Constants.App;
|
||||
using Mear.Models;
|
||||
|
||||
namespace Mear.Repositories.Database
|
||||
{
|
||||
public class DBSongRepository : DBRepository
|
||||
{
|
||||
#region Fields
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public DBSongRepository()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
public Song RetrieveSong(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var song = _Db.Table<Song>().Where(s => s.Id == id).First();
|
||||
|
||||
return song;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public Song RetrieveSong(string artist, string title)
|
||||
{
|
||||
try
|
||||
{
|
||||
var song = _Db.Table<Song>().Where(s =>
|
||||
(s.Artist.Equals(artist) && s.Title.Equals(title))).First();
|
||||
|
||||
return song;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SaveSong(Song song)
|
||||
{
|
||||
if (!DoesTableExist("Song"))
|
||||
{
|
||||
_Db.CreateTable<Song>();
|
||||
}
|
||||
|
||||
_Db.Insert(song);
|
||||
}
|
||||
public void UpdateSong(Song song)
|
||||
{
|
||||
if (!DoesTableExist("Song"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Implement functionality for udpating song
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Mear.Views.MearPlayerView" >
|
||||
<ContentPage.Content>
|
||||
<StackLayout>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image x:Name="SongCover"
|
||||
Grid.Row="0"
|
||||
Source="" />
|
||||
|
||||
<StackLayout Orientation="Horizontal"
|
||||
Grid.Row="2">
|
||||
<Label x:Name="StartTime"
|
||||
Text="0:00" />
|
||||
<ProgressBar x:Name="SongProgress"
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
Progress="0.7" />
|
||||
<Label x:Name="EndTime"
|
||||
Text="0:00" />
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal"
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
Grid.Row="3"
|
||||
Spacing="5">
|
||||
<Button x:Name="Previous"
|
||||
Text="Prev"
|
||||
Clicked="Previous_Clicked" />
|
||||
<Button x:Name="Play"
|
||||
Text="Ply"
|
||||
Clicked="Play_Clicked" />
|
||||
<Button x:Name="Next"
|
||||
Text="Nxt"
|
||||
Clicked="Next_Clicked" />
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Mear.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class MearPlayerView : ContentPage
|
||||
{
|
||||
public MearPlayerView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Previous_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Play_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Next_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ namespace Mear.Views
|
||||
{
|
||||
var song = (Song)SongListView.SelectedItem;
|
||||
await MearPlayer.StreamSongDemoAsync(song);
|
||||
await Navigation.PushModalAsync(new MearPlayerView());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user