mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-08 16:24:49 +00:00
Making cast work a little more.
This commit is contained in:
@@ -621,7 +621,9 @@ namespace MusicApp
|
||||
ShowQuickPlay();
|
||||
if (Home.instance != null && !specialSwitch)
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
Home.instance.Refresh();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1219,10 +1221,6 @@ namespace MusicApp
|
||||
|
||||
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
current.queueSlot = 0;
|
||||
MusicPlayer.queue.Clear();
|
||||
MusicPlayer.queue.Add(current);
|
||||
MusicPlayer.currentID = 0;
|
||||
|
||||
Random r = new Random();
|
||||
tracks = tracks.OrderBy(x => r.Next()).ToList();
|
||||
@@ -1241,7 +1239,7 @@ namespace MusicApp
|
||||
await Task.Delay(10);
|
||||
}
|
||||
foreach (Song song in tracks)
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
MusicPlayer.instance.PlayLastInQueue(song);
|
||||
|
||||
ShowSmallPlayer();
|
||||
ShowPlayer();
|
||||
@@ -1514,6 +1512,8 @@ namespace MusicApp
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
YoutubeEngine.instances = null;
|
||||
|
||||
if (MusicPlayer.instance != null && !MusicPlayer.isRunning && Preferences.instance == null && Queue.instance == null && EditMetaData.instance == null)
|
||||
{
|
||||
Intent intent = new Intent(this, typeof(MusicPlayer));
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
instance = null;
|
||||
}
|
||||
|
||||
#pragma warning disable CS4014
|
||||
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
view = inflater.Inflate(Resource.Layout.RecyclerFragment, container, false);
|
||||
@@ -58,8 +59,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
PopulateSongs();
|
||||
return view;
|
||||
}
|
||||
#pragma warning restore CS4014
|
||||
|
||||
private async void PopulateSongs()
|
||||
private async Task PopulateSongs()
|
||||
{
|
||||
if (!populating)
|
||||
{
|
||||
@@ -427,15 +429,15 @@ namespace MusicApp.Resources.Portable_Class
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void OnRefresh(object sender, EventArgs e)
|
||||
public async void OnRefresh(object sender, EventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
await Refresh();
|
||||
MainActivity.instance.contentRefresh.Refreshing = false;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
public async Task Refresh()
|
||||
{
|
||||
PopulateSongs();
|
||||
await PopulateSongs();
|
||||
}
|
||||
|
||||
public void LoadMore()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Android.Content;
|
||||
using Android.Database;
|
||||
using Android.Gms.Cast;
|
||||
using Android.Gms.Cast.Framework;
|
||||
using Android.Gms.Cast.Framework.Media;
|
||||
using Android.Graphics;
|
||||
using Android.Media;
|
||||
@@ -218,6 +217,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
song = new Song(title, artist, thumbnailURI, youtubeID, -1, -1, filePath, true);
|
||||
}
|
||||
|
||||
if (addToQueue)
|
||||
song.queueSlot = CurrentID() + 1;
|
||||
|
||||
isLiveStream = isLive;
|
||||
|
||||
if (!UseCastPlayer)
|
||||
@@ -299,6 +301,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateQueueSlots();
|
||||
currentID = song.queueSlot;
|
||||
}
|
||||
|
||||
@@ -323,6 +326,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
if (player == null)
|
||||
InitializeService();
|
||||
|
||||
if (addToQueue)
|
||||
song.queueSlot = CurrentID() + 1;
|
||||
|
||||
if (!UseCastPlayer)
|
||||
{
|
||||
if (mediaSession == null)
|
||||
@@ -402,6 +408,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateQueueSlots();
|
||||
currentID = song.queueSlot;
|
||||
}
|
||||
|
||||
@@ -926,10 +933,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
}
|
||||
|
||||
//if (UseCastPlayer)
|
||||
// RemoteMediaClient.QueueJumpToItem()
|
||||
//else
|
||||
Play(song, false, (currentID == song.queueSlot ? LastTimer : 0));
|
||||
if (UseCastPlayer)
|
||||
RemotePlayer.QueueJumpToItem(RemotePlayer.MediaStatus.GetItemByIndex(song.queueSlot).ItemId, null);
|
||||
else
|
||||
Play(song, false, (currentID == song.queueSlot ? LastTimer : 0));
|
||||
|
||||
if (showPlayer)
|
||||
{
|
||||
@@ -939,9 +946,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public static int CurrentID()
|
||||
{
|
||||
Console.WriteLine("&CurretID: " + currentID);
|
||||
Console.WriteLine("&QueueCount: " + queue.Count);
|
||||
|
||||
if (queue.Count <= currentID)
|
||||
currentID = -1;
|
||||
return currentID;
|
||||
@@ -1440,10 +1444,26 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
if (UseCastPlayer)
|
||||
{
|
||||
Console.WriteLine("&Getting queue from cast");
|
||||
|
||||
Console.WriteLine("&MediaStatus: " + RemotePlayer?.MediaStatus);
|
||||
Console.WriteLine("&QueueItems: " + RemotePlayer?.MediaStatus?.QueueItems);
|
||||
Console.WriteLine("&Count: " + RemotePlayer?.MediaStatus?.QueueItems.Count);
|
||||
|
||||
if (RemotePlayer?.MediaStatus == null)
|
||||
{
|
||||
Toast.MakeText(MainActivity.instance, "MediaStatus == null", ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
if (RemotePlayer?.MediaStatus?.QueueItems.Count == 0)
|
||||
{
|
||||
Toast.MakeText(MainActivity.instance, "QueueItems count == 0", ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Song> list = RemotePlayer?.MediaStatus?.QueueItems?.ToList().ConvertAll(GetSongFromQueueItem);
|
||||
queue = list ?? queue;
|
||||
|
||||
Console.WriteLine("&Getting queue from cast");
|
||||
foreach (Song song in queue)
|
||||
Console.WriteLine("&" + song.Title);
|
||||
|
||||
@@ -1458,6 +1478,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
Console.WriteLine("&CurrentID: " + currentID);
|
||||
|
||||
while (Player.instance == null)
|
||||
await Task.Delay(1000);
|
||||
|
||||
if(instance != null)
|
||||
instance.OnStatusUpdated();
|
||||
else
|
||||
@@ -1471,12 +1494,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
Home.instance?.AddQueue();
|
||||
Home.instance?.RefreshQueue();
|
||||
MainActivity.instance?.ShowSmallPlayer();
|
||||
Queue.instance?.Refresh();
|
||||
|
||||
while (Player.instance == null)
|
||||
await Task.Delay(100);
|
||||
|
||||
MainActivity.instance.FindViewById(Resource.Id.playerSheet).Visibility = ViewStates.Visible;
|
||||
MainActivity.instance.FindViewById<FrameLayout>(Resource.Id.contentView).SetPadding(0, 0, 0, MainActivity.instance.DpToPx(70));
|
||||
Player.instance.RefreshPlayer();
|
||||
}
|
||||
}
|
||||
@@ -1617,7 +1638,19 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public void OnMetadataUpdated()
|
||||
{
|
||||
GetQueueFromCast();
|
||||
Console.WriteLine("&MetaData Updated");
|
||||
int? id = RemotePlayer?.MediaStatus?.CurrentItemId;
|
||||
if (id != null && id != 0)
|
||||
{
|
||||
int? index = (int?)RemotePlayer.MediaStatus.GetIndexById((int)id);
|
||||
currentID = index ?? -1;
|
||||
}
|
||||
else
|
||||
currentID = -1;
|
||||
|
||||
Console.WriteLine("&CurrentID: " + currentID);
|
||||
|
||||
Player.instance?.RefreshPlayer();
|
||||
}
|
||||
|
||||
public void OnPreloadStatusUpdated()
|
||||
@@ -1628,6 +1661,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public void OnQueueStatusUpdated()
|
||||
{
|
||||
Console.WriteLine("&Queue status updated");
|
||||
GetQueueFromCast();
|
||||
}
|
||||
|
||||
public void OnSendingRemoteMediaRequest()
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public async void RefreshPlayer()
|
||||
{
|
||||
while (MusicPlayer.CurrentID() == -1)
|
||||
while (MainActivity.instance == null || MusicPlayer.CurrentID() == -1)
|
||||
await Task.Delay(100);
|
||||
|
||||
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
RecyclerHolder holder = (RecyclerHolder)viewHolder;
|
||||
|
||||
holder.Title.Text = songList[position].Title;
|
||||
holder.Title.Text = songList[position].queueSlot + " " + songList[position].Title;
|
||||
holder.Artist.Text = songList[position].Artist;
|
||||
|
||||
if (songList[position].AlbumArt == -1 || songList[position].IsYt)
|
||||
|
||||
Reference in New Issue
Block a user