mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-01 05:37:42 +00:00
Solving bugs with cast player.
This commit is contained in:
@@ -5,11 +5,19 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
public class CastQueueManager : MediaQueue.Callback
|
||||
{
|
||||
public override void ItemsInsertedInRange(int insertIndex, int insertCount)
|
||||
{
|
||||
base.ItemsInsertedInRange(insertIndex, insertCount);
|
||||
if(MusicPlayer.queue.Count == insertCount)
|
||||
MainActivity.instance.ShowSmallPlayer();
|
||||
}
|
||||
|
||||
public override void ItemsReloaded()
|
||||
{
|
||||
base.ItemsReloaded();
|
||||
Queue.instance?.adapter.NotifyDataSetChanged();
|
||||
Home.instance?.QueueAdapter?.NotifyDataSetChanged();
|
||||
Player.instance?.RefreshPlayer();
|
||||
}
|
||||
|
||||
public override void ItemsRemovedAtIndexes(int[] indexes)
|
||||
@@ -19,12 +27,16 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
Queue.instance?.adapter.NotifyItemRemoved(index);
|
||||
Home.instance?.QueueAdapter?.NotifyItemRemoved(index);
|
||||
|
||||
if (index == MusicPlayer.CurrentID())
|
||||
Player.instance.RefreshPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ItemsUpdatedAtIndexes(int[] indexes)
|
||||
{
|
||||
base.ItemsUpdatedAtIndexes(indexes);
|
||||
System.Console.WriteLine("&Item Updated at Index");
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
Song song = (Song)MusicPlayer.RemotePlayer.MediaQueue.GetItemAtIndex(index);
|
||||
@@ -46,6 +58,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
Queue.instance?.adapter.NotifyItemChanged(index, song.Title);
|
||||
Home.instance?.QueueAdapter?.NotifyItemChanged(index, song.Title);
|
||||
|
||||
if (index == MusicPlayer.CurrentID())
|
||||
Player.instance.RefreshPlayer();
|
||||
}
|
||||
|
||||
MusicPlayer.WaitForIndex.Remove(index);
|
||||
|
||||
@@ -1518,11 +1518,11 @@ namespace MusicApp.Resources.Portable_Class
|
||||
RemotePlayer.Play();
|
||||
|
||||
Initialized = true;
|
||||
GetQueueFromCast();
|
||||
GetQueueFromCast(true);
|
||||
}
|
||||
}
|
||||
|
||||
public async static void GetQueueFromCast()
|
||||
public async static void GetQueueFromCast(bool forceShowPlayer = false)
|
||||
{
|
||||
if (UseCastPlayer && Initialized)
|
||||
{
|
||||
@@ -1530,6 +1530,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
currentID = RemotePlayer.MediaQueue.IndexOfItemWithId(RemotePlayer.CurrentItem.ItemId);
|
||||
|
||||
bool showPlayer = queue.Count == 0;
|
||||
if (forceShowPlayer)
|
||||
showPlayer = true;
|
||||
|
||||
queue.Clear();
|
||||
for (int i = 0; i < RemotePlayer.MediaQueue.ItemCount; i++)
|
||||
@@ -1547,9 +1549,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
Console.WriteLine("&Fetched");
|
||||
|
||||
foreach (Song song in queue)
|
||||
Console.WriteLine("&Song: " + song?.Title);
|
||||
|
||||
Intent intent = new Intent(MainActivity.instance, typeof(MusicPlayer));
|
||||
intent.SetAction("CastListener");
|
||||
MainActivity.instance.StartService(intent);
|
||||
@@ -1569,7 +1568,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (noisyRegistered)
|
||||
|
||||
@@ -320,6 +320,11 @@ namespace MusicApp.Resources.Portable_Class
|
||||
else if (MusicPlayer.currentID == fromPosition)
|
||||
MusicPlayer.currentID = toPosition;
|
||||
|
||||
if (MusicPlayer.UseCastPlayer)
|
||||
{
|
||||
int nextItemID = MusicPlayer.RemotePlayer.MediaQueue.ItemCount > toPosition ? MusicPlayer.RemotePlayer.MediaQueue.ItemIdAtIndex(toPosition + 1) : 0; //0 = InvalidItemID = end of the queue
|
||||
MusicPlayer.RemotePlayer.QueueReorderItems(new int[] { MusicPlayer.RemotePlayer.MediaQueue.ItemIdAtIndex(fromPosition) }, nextItemID, null);
|
||||
}
|
||||
MusicPlayer.UpdateQueueDataBase();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user