mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Small player finished
This commit is contained in:
@@ -9,9 +9,11 @@ using Android.Support.V4.View;
|
||||
using Android.Runtime;
|
||||
using Android.Widget;
|
||||
using Android.Content;
|
||||
using MusicApp.Resources.values;
|
||||
using Square.Picasso;
|
||||
using System;
|
||||
|
||||
using SearchView = Android.Support.V7.Widget.SearchView;
|
||||
using static Android.App.ActivityManager;
|
||||
|
||||
namespace MusicApp
|
||||
{
|
||||
@@ -22,6 +24,11 @@ namespace MusicApp
|
||||
public Android.Support.V7.Widget.Toolbar ToolBar;
|
||||
public IMenu menu;
|
||||
|
||||
private Handler handler = new Handler();
|
||||
private ProgressBar bar;
|
||||
private bool prepared = false;
|
||||
|
||||
|
||||
public static int paddingBot
|
||||
{
|
||||
get
|
||||
@@ -196,14 +203,7 @@ namespace MusicApp
|
||||
case Resource.Id.musicLayout:
|
||||
HideTabs();
|
||||
HideSearch();
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
fragment = Player.NewInstance();
|
||||
break;
|
||||
}
|
||||
if(fragment == null)
|
||||
fragment = Queue.NewInstance();
|
||||
|
||||
fragment = Queue.NewInstance();
|
||||
break;
|
||||
|
||||
case Resource.Id.browseLayout:
|
||||
@@ -239,7 +239,6 @@ namespace MusicApp
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
tabs.RemoveAllTabs();
|
||||
tabs.AddTab(tabs.NewTab().SetText("Songs"));
|
||||
//tabs.AddTab(tabs.NewTab().SetText("Artist"));
|
||||
tabs.AddTab(tabs.NewTab().SetText("Folders"));
|
||||
ViewPager pager = FindViewById<ViewPager>(Resource.Id.pager);
|
||||
pager.SetPadding(0, 200, 0, 0);
|
||||
@@ -247,7 +246,6 @@ namespace MusicApp
|
||||
ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);
|
||||
|
||||
adapter.AddFragment(Browse.NewInstance(), "Songs");
|
||||
//adapter.AddFragment(DownloadFragment.NewInstance(), "Artists");
|
||||
adapter.AddFragment(FolderBrowse.NewInstance(), "Folders");
|
||||
|
||||
pager.Adapter = adapter;
|
||||
@@ -277,5 +275,95 @@ namespace MusicApp
|
||||
FrameLayout frame = FindViewById<FrameLayout>(Resource.Id.contentView);
|
||||
frame.Visibility = ViewStates.Visible;
|
||||
}
|
||||
|
||||
public void PrepareSmallPlayer()
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
SetSmallPlayerProgressBar();
|
||||
|
||||
if (!prepared)
|
||||
{
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
|
||||
smallPlayer.FindViewById<LinearLayout>(Resource.Id.spContainer).Click += Container_Click;
|
||||
prepared = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowSmallPlayer()
|
||||
{
|
||||
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
StartService(intent);
|
||||
}
|
||||
|
||||
private void Container_Click(object sender, EventArgs e)
|
||||
{
|
||||
HideTabs();
|
||||
HideSearch();
|
||||
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).Commit();
|
||||
}
|
||||
|
||||
void SetSmallPlayerProgressBar()
|
||||
{
|
||||
bar = FindViewById<ProgressBar>(Resource.Id.spProgress);
|
||||
bar.Max = MusicPlayer.Duration;
|
||||
bar.Progress = MusicPlayer.CurrentPosition;
|
||||
handler.PostDelayed(UpdateProgressBar, 1000);
|
||||
}
|
||||
|
||||
private void UpdateProgressBar()
|
||||
{
|
||||
if (!MusicPlayer.isRunning)
|
||||
{
|
||||
handler.RemoveCallbacks(UpdateProgressBar);
|
||||
return;
|
||||
}
|
||||
|
||||
bar.Progress = MusicPlayer.CurrentPosition;
|
||||
handler.PostDelayed(UpdateProgressBar, 1000);
|
||||
}
|
||||
|
||||
public void HideSmallPlayer()
|
||||
{
|
||||
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,62 +40,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
emptyView = LayoutInflater.Inflate(Resource.Layout.NoSong, null);
|
||||
ListView.EmptyView = emptyView;
|
||||
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
}
|
||||
|
||||
if (ListView.Adapter == null)
|
||||
GetStoragePermission();
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click -= Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click -= Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click -= Next_Click;
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
|
||||
@@ -34,59 +34,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView.ItemLongClick += ListView_ItemLongClick; ;
|
||||
ListAdapter = null;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click -= Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click -= Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click -= Next_Click;
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
@@ -99,10 +50,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
View view = base.OnCreateView(inflater, container, savedInstanceState);
|
||||
if (!MusicPlayer.isRunning)
|
||||
view.SetPadding(0, 100, 0, 0);
|
||||
else
|
||||
view.SetPadding(0, 360, 0, 0);
|
||||
view.SetPadding(0, 100, 0, MainActivity.paddingBot);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ using System.Threading.Tasks;
|
||||
using Square.Picasso;
|
||||
|
||||
using Uri = Android.Net.Uri;
|
||||
using FileNotFoundException = System.IO.FileNotFoundException;
|
||||
using Android.Widget;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
@@ -139,7 +138,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
player.Reset();
|
||||
InitializePlayer();
|
||||
await player.SetDataSourceAsync(Application.Context, Android.Net.Uri.Parse(filePath));
|
||||
await player.SetDataSourceAsync(Application.Context, Uri.Parse(filePath));
|
||||
player.PrepareAsync();
|
||||
GetTrackSong(filePath, out Song song);
|
||||
CreateNotification(song.GetName(), song.GetArtist(), song.GetAlbumArt());
|
||||
@@ -208,7 +207,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
player.PrepareAsync();
|
||||
CreateNotification(title, artist, 0, imageURL);
|
||||
|
||||
queue.Clear();
|
||||
Song item = new Song(title, artist, imageURL, -1, 1, url);
|
||||
queue.Add(item);
|
||||
@@ -322,6 +320,14 @@ namespace MusicApp.Resources.Portable_Class
|
||||
};
|
||||
}
|
||||
|
||||
public static int Duration
|
||||
{
|
||||
get
|
||||
{
|
||||
return player.Duration;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CurrentPosition
|
||||
{
|
||||
get
|
||||
@@ -490,7 +496,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public void Stop()
|
||||
{
|
||||
isRunning = false;
|
||||
if(player != null)
|
||||
MainActivity.instance.HideSmallPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
if (player.IsPlaying)
|
||||
player.Stop();
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
MainActivity.instance.ToolBar.Visibility = ViewStates.Visible;
|
||||
MainActivity.instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).Visibility = ViewStates.Visible;
|
||||
MainActivity.instance.ShowSmallPlayer();
|
||||
MainActivity.instance.PrepareSmallPlayer();
|
||||
base.OnDestroy();
|
||||
instance = null;
|
||||
}
|
||||
@@ -58,6 +60,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
async void CreatePlayer()
|
||||
{
|
||||
MainActivity.instance.HideSmallPlayer();
|
||||
|
||||
while (MusicPlayer.CurrentID() == -1)
|
||||
await Task.Delay(100);
|
||||
|
||||
@@ -172,7 +176,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bar.Progress = MusicPlayer.CurrentPosition;
|
||||
handler.PostDelayed(UpdateSeekBar, 1000);
|
||||
}
|
||||
|
||||
@@ -39,60 +39,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
if(ListView.Adapter == null)
|
||||
GetStoragePermission();
|
||||
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click -= Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click -= Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click -= Next_Click;
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
|
||||
@@ -40,60 +40,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
PopulateList();
|
||||
MainActivity.instance.DisplaySearch(1);
|
||||
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click -= Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click -= Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click -= Next_Click;
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
|
||||
@@ -26,60 +26,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView.EmptyView = emptyView;
|
||||
|
||||
PopulateView();
|
||||
|
||||
if (MusicPlayer.isRunning)
|
||||
{
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout) smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Visible;
|
||||
smallPlayer.Visibility = ViewStates.Visible;
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = current.GetName();
|
||||
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = current.GetArtist();
|
||||
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
|
||||
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, current.GetAlbumArt());
|
||||
|
||||
Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Into(art);
|
||||
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click += Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click += Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click += Next_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void Last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Previus");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Pause");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
|
||||
intent.SetAction("Next");
|
||||
Activity.StartService(intent);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
RelativeLayout smallPlayer = Activity.FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
|
||||
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
|
||||
parent.Visibility = ViewStates.Gone;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spLast).Click -= Last_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spPlay).Click -= Play_Click;
|
||||
smallPlayer.FindViewById<ImageButton>(Resource.Id.spNext).Click -= Next_Click;
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
|
||||
71
MusicApp/Resources/Resource.Designer.cs
generated
71
MusicApp/Resources/Resource.Designer.cs
generated
@@ -2464,8 +2464,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f07001e
|
||||
public const int add = 2131165214;
|
||||
|
||||
// aapt resource value: 0x7f0700c3
|
||||
public const int albumArt = 2131165379;
|
||||
// aapt resource value: 0x7f0700c4
|
||||
public const int albumArt = 2131165380;
|
||||
|
||||
// aapt resource value: 0x7f070058
|
||||
public const int alertTitle = 2131165272;
|
||||
@@ -2476,8 +2476,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f070023
|
||||
public const int always = 2131165219;
|
||||
|
||||
// aapt resource value: 0x7f0700c4
|
||||
public const int artist = 2131165380;
|
||||
// aapt resource value: 0x7f0700c5
|
||||
public const int artist = 2131165381;
|
||||
|
||||
// aapt resource value: 0x7f07002f
|
||||
public const int auto = 2131165231;
|
||||
@@ -2491,8 +2491,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f07008c
|
||||
public const int bottomView = 2131165324;
|
||||
|
||||
// aapt resource value: 0x7f0700c9
|
||||
public const int browseLayout = 2131165385;
|
||||
// aapt resource value: 0x7f0700ca
|
||||
public const int browseLayout = 2131165386;
|
||||
|
||||
// aapt resource value: 0x7f070073
|
||||
public const int browseList = 2131165299;
|
||||
@@ -2572,8 +2572,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f0700b4
|
||||
public const int downFAB = 2131165364;
|
||||
|
||||
// aapt resource value: 0x7f0700ca
|
||||
public const int downloadLayout = 2131165386;
|
||||
// aapt resource value: 0x7f0700cb
|
||||
public const int downloadLayout = 2131165387;
|
||||
|
||||
// aapt resource value: 0x7f070066
|
||||
public const int edit_query = 2131165286;
|
||||
@@ -2665,8 +2665,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f0700a1
|
||||
public const int line1 = 2131165345;
|
||||
|
||||
// aapt resource value: 0x7f0700c5
|
||||
public const int line2 = 2131165381;
|
||||
// aapt resource value: 0x7f0700c6
|
||||
public const int line2 = 2131165382;
|
||||
|
||||
// aapt resource value: 0x7f0700a3
|
||||
public const int line3 = 2131165347;
|
||||
@@ -2680,8 +2680,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f070048
|
||||
public const int list_item = 2131165256;
|
||||
|
||||
// aapt resource value: 0x7f0700c7
|
||||
public const int masked = 2131165383;
|
||||
// aapt resource value: 0x7f0700c8
|
||||
public const int masked = 2131165384;
|
||||
|
||||
// aapt resource value: 0x7f070095
|
||||
public const int media_actions = 2131165333;
|
||||
@@ -2695,8 +2695,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f070019
|
||||
public const int multiply = 2131165209;
|
||||
|
||||
// aapt resource value: 0x7f0700c8
|
||||
public const int musicLayout = 2131165384;
|
||||
// aapt resource value: 0x7f0700c9
|
||||
public const int musicLayout = 2131165385;
|
||||
|
||||
// aapt resource value: 0x7f07007d
|
||||
public const int navigation_header_container = 2131165309;
|
||||
@@ -2767,8 +2767,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f0700ad
|
||||
public const int playerTitle = 2131165357;
|
||||
|
||||
// aapt resource value: 0x7f0700cb
|
||||
public const int playlistLayout = 2131165387;
|
||||
// aapt resource value: 0x7f0700cc
|
||||
public const int playlistLayout = 2131165388;
|
||||
|
||||
// aapt resource value: 0x7f070074
|
||||
public const int playlistName = 2131165300;
|
||||
@@ -2851,8 +2851,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f070072
|
||||
public const int select_dialog_listview = 2131165298;
|
||||
|
||||
// aapt resource value: 0x7f0700cc
|
||||
public const int settings = 2131165388;
|
||||
// aapt resource value: 0x7f0700cd
|
||||
public const int settings = 2131165389;
|
||||
|
||||
// aapt resource value: 0x7f07005c
|
||||
public const int shortcut = 2131165276;
|
||||
@@ -2884,26 +2884,29 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f0700b3
|
||||
public const int songTimer = 2131165363;
|
||||
|
||||
// aapt resource value: 0x7f0700bc
|
||||
public const int spArt = 2131165372;
|
||||
|
||||
// aapt resource value: 0x7f0700be
|
||||
public const int spArtist = 2131165374;
|
||||
|
||||
// aapt resource value: 0x7f0700c1
|
||||
public const int spLast = 2131165377;
|
||||
// aapt resource value: 0x7f0700bd
|
||||
public const int spArt = 2131165373;
|
||||
|
||||
// aapt resource value: 0x7f0700bf
|
||||
public const int spNext = 2131165375;
|
||||
public const int spArtist = 2131165375;
|
||||
|
||||
// aapt resource value: 0x7f0700c0
|
||||
public const int spPlay = 2131165376;
|
||||
// aapt resource value: 0x7f0700bc
|
||||
public const int spContainer = 2131165372;
|
||||
|
||||
// aapt resource value: 0x7f0700c2
|
||||
public const int spProgress = 2131165378;
|
||||
public const int spLast = 2131165378;
|
||||
|
||||
// aapt resource value: 0x7f0700bd
|
||||
public const int spTitle = 2131165373;
|
||||
// aapt resource value: 0x7f0700c0
|
||||
public const int spNext = 2131165376;
|
||||
|
||||
// aapt resource value: 0x7f0700c1
|
||||
public const int spPlay = 2131165377;
|
||||
|
||||
// aapt resource value: 0x7f0700c3
|
||||
public const int spProgress = 2131165379;
|
||||
|
||||
// aapt resource value: 0x7f0700be
|
||||
public const int spTitle = 2131165374;
|
||||
|
||||
// aapt resource value: 0x7f07004c
|
||||
public const int spacer = 2131165260;
|
||||
@@ -3007,8 +3010,8 @@ namespace MusicApp
|
||||
// aapt resource value: 0x7f07000e
|
||||
public const int view_offset_helper = 2131165198;
|
||||
|
||||
// aapt resource value: 0x7f0700c6
|
||||
public const int visible = 2131165382;
|
||||
// aapt resource value: 0x7f0700c7
|
||||
public const int visible = 2131165383;
|
||||
|
||||
// aapt resource value: 0x7f070027
|
||||
public const int withText = 2131165223;
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
app:menu="@menu/bottom_items" />
|
||||
<FrameLayout
|
||||
android:layout_height="70dp"
|
||||
android:visibility="gone"
|
||||
android:layout_below="@id/bottomView"
|
||||
android:layout_width="match_parent" >
|
||||
<include
|
||||
|
||||
@@ -6,23 +6,30 @@
|
||||
android:id="@+id/smallPlayer" >
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:id="@+id/spContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
<ImageView
|
||||
android:id="@+id/spArt"
|
||||
android:layout_width="70dp"
|
||||
android:clickable="false"
|
||||
android:layout_height="70dp"
|
||||
android:src="@drawable/noAlbum"
|
||||
android:layout_gravity="left|center" />
|
||||
android:layout_gravity="left"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="130dp"
|
||||
android:clickable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/spTitle"
|
||||
android:text="Title"
|
||||
android:clickable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
@@ -34,6 +41,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:clickable="false"
|
||||
android:textSize="14dip"
|
||||
android:textColor="#4f5b62" />
|
||||
</LinearLayout>
|
||||
@@ -67,9 +75,9 @@
|
||||
<ProgressBar
|
||||
android:id="@+id/spProgress"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
android:paddingLeft="70dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
android:layout_gravity="top"
|
||||
android:layout_toRightOf="@id/spArt"
|
||||
android:layout_alignParentTop="true"
|
||||
android:progress="25"/>
|
||||
</RelativeLayout >
|
||||
Reference in New Issue
Block a user