mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-03 22:40:52 +00:00
Reworking player and playlist track browse.
Adding play in order for playlists and folders.
This commit is contained in:
+71
-25
@@ -47,6 +47,8 @@ namespace MusicApp
|
||||
public static int dialogTheme;
|
||||
public static IParcelable parcelable;
|
||||
public static string parcelableSender;
|
||||
public IParcelable youtubeParcel;
|
||||
public string youtubeInstanceSave;
|
||||
|
||||
public Android.Support.V7.Widget.Toolbar ToolBar;
|
||||
public bool NoToolbarMenu = false;
|
||||
@@ -75,7 +77,7 @@ namespace MusicApp
|
||||
public GoogleApiClient googleClient;
|
||||
private bool canAsk;
|
||||
private bool waitingForYoutube;
|
||||
private bool ResumeKiller;
|
||||
public bool ResumeKiller;
|
||||
|
||||
public event EventHandler<PaddingChange> OnPaddingChanged;
|
||||
|
||||
@@ -419,6 +421,33 @@ namespace MusicApp
|
||||
Navigate(Resource.Id.musicLayout);
|
||||
HomeDetails = false;
|
||||
}
|
||||
else if(youtubeInstanceSave != null)
|
||||
{
|
||||
int selectedTab = 0;
|
||||
switch (youtubeInstanceSave)
|
||||
{
|
||||
case "YoutubeEngine-All":
|
||||
selectedTab = 0;
|
||||
break;
|
||||
case "YoutubeEngine-Tracks":
|
||||
selectedTab = 1;
|
||||
break;
|
||||
case "YoutubeEngine-Playlists":
|
||||
selectedTab = 2;
|
||||
break;
|
||||
case "YoutubeEngine-Channels":
|
||||
selectedTab = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SetYtTabs(YoutubeEngine.searchKeyWorld, selectedTab);
|
||||
YoutubeEngine.instances[selectedTab].focused = true;
|
||||
YoutubeEngine.instances[selectedTab].OnFocus();
|
||||
//YoutubeEngine.instances[selectedTab].ListView.GetLayoutManager().OnRestoreInstanceState(youtubeParcel);
|
||||
youtubeInstanceSave = null;
|
||||
youtubeParcel = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigate(Resource.Id.playlistLayout);
|
||||
@@ -449,6 +478,9 @@ namespace MusicApp
|
||||
|
||||
public bool OnMenuItemActionCollapse(IMenuItem item) //Youtube search collapse
|
||||
{
|
||||
if (YoutubeEngine.instances == null)
|
||||
return true;
|
||||
|
||||
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
foreach (YoutubeEngine instance in YoutubeEngine.instances)
|
||||
{
|
||||
@@ -671,7 +703,7 @@ namespace MusicApp
|
||||
CanSwitchDelay();
|
||||
}
|
||||
|
||||
async void SetYtTabs(string querry, int selectedTab = 0)
|
||||
public async void SetYtTabs(string querry, int selectedTab = 0)
|
||||
{
|
||||
while (!canSwitch)
|
||||
await Task.Delay(10);
|
||||
@@ -703,12 +735,6 @@ namespace MusicApp
|
||||
|
||||
pager.Adapter = oldAdapter;
|
||||
}
|
||||
else if(YoutubeEngine.instances != null)
|
||||
{
|
||||
contentRefresh.Visibility = ViewStates.Gone;
|
||||
pagerRefresh.Visibility = ViewStates.Visible;
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
contentRefresh.Visibility = ViewStates.Gone;
|
||||
@@ -923,7 +949,28 @@ namespace MusicApp
|
||||
|
||||
private void Container_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveInstance();
|
||||
if (YoutubeEngine.instances != null)
|
||||
{
|
||||
YoutubeEngine instance = null;
|
||||
foreach (YoutubeEngine inst in YoutubeEngine.instances)
|
||||
if (instance.focused)
|
||||
instance = inst;
|
||||
|
||||
youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
|
||||
|
||||
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
foreach (YoutubeEngine inst in YoutubeEngine.instances)
|
||||
{
|
||||
MainActivity.instance.OnPaddingChanged -= inst.OnPaddingChanged;
|
||||
rootView.RemoveView(inst.emptyView);
|
||||
}
|
||||
rootView.RemoveView(YoutubeEngine.loadingView);
|
||||
YoutubeEngine.instances = null;
|
||||
}
|
||||
else
|
||||
MainActivity.instance.SaveInstance();
|
||||
|
||||
HideTabs();
|
||||
HideSearch();
|
||||
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).AddToBackStack(null).Commit();
|
||||
@@ -1244,23 +1291,23 @@ namespace MusicApp
|
||||
return (int) (px * scale + 0.5f);
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
{
|
||||
base.OnResume();
|
||||
//protected override void OnResume()
|
||||
//{
|
||||
// base.OnResume();
|
||||
|
||||
if(parcelableSender != null && !ResumeKiller)
|
||||
{
|
||||
var searchView = menu.FindItem(Resource.Id.search).ActionView.JavaCast<SearchView>();
|
||||
menu.FindItem(Resource.Id.search).CollapseActionView();
|
||||
searchView.ClearFocus();
|
||||
searchView.Iconified = true;
|
||||
searchView.SetQuery("", false);
|
||||
ResumeInstance();
|
||||
}
|
||||
// if(parcelableSender != null && !ResumeKiller)
|
||||
// {
|
||||
// var searchView = menu.FindItem(Resource.Id.search).ActionView.JavaCast<SearchView>();
|
||||
// menu.FindItem(Resource.Id.search).CollapseActionView();
|
||||
// searchView.ClearFocus();
|
||||
// searchView.Iconified = true;
|
||||
// searchView.SetQuery("", false);
|
||||
// ResumeInstance();
|
||||
// }
|
||||
|
||||
if (ResumeKiller)
|
||||
ResumeKiller = false;
|
||||
}
|
||||
// if (ResumeKiller)
|
||||
// ResumeKiller = false;
|
||||
//}
|
||||
|
||||
public void SaveInstance()
|
||||
{
|
||||
@@ -1307,7 +1354,6 @@ namespace MusicApp
|
||||
|
||||
public void ResumeInstance()
|
||||
{
|
||||
Console.WriteLine("&Resuming " + parcelableSender);
|
||||
switch (parcelableSender)
|
||||
{
|
||||
case "Home":
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.musicapp.android" android:installLocation="preferExternal" android:versionCode="3" android:versionName="1.3">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.musicapp.android" android:installLocation="preferExternal" android:versionCode="4" android:versionName="1.4">
|
||||
<uses-sdk android:minSdkVersion="21" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
@@ -145,6 +145,17 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
if (MainActivity.paddingBot > MainActivity.defaultPaddingBot && adapter.listPadding == 0)
|
||||
adapter.listPadding = MainActivity.paddingBot - MainActivity.defaultPaddingBot;
|
||||
|
||||
if(result != null)
|
||||
{
|
||||
if (adapter != null)
|
||||
listPadding = adapter.listPadding;
|
||||
adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, result)
|
||||
{
|
||||
listPadding = listPadding
|
||||
};
|
||||
ListAdapter = adapter;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefresh(object sender, System.EventArgs e)
|
||||
|
||||
@@ -11,6 +11,7 @@ using Android.Views;
|
||||
using Android.Widget;
|
||||
using MusicApp.Resources.values;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public bool focused = false;
|
||||
|
||||
private View view;
|
||||
private string[] actions = new string[] { "List songs", "Add To Playlist", "Random Play" };
|
||||
private string[] actions = new string[] { "List songs", "Play in order", "Add To Playlist", "Random Play" };
|
||||
private bool isEmpty = false;
|
||||
|
||||
|
||||
@@ -215,9 +216,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListSongs(displayPath, path);
|
||||
break;
|
||||
case 1:
|
||||
GetPlaylist(path);
|
||||
PlayInOrder(path);
|
||||
break;
|
||||
case 2:
|
||||
GetPlaylist(path);
|
||||
break;
|
||||
case 3:
|
||||
RandomPlay(path);
|
||||
break;
|
||||
default:
|
||||
@@ -238,6 +242,59 @@ namespace MusicApp.Resources.Portable_Class
|
||||
MainActivity.instance.Transition(Resource.Id.contentView, FolderTracks.NewInstance(path, displayPath), true);
|
||||
}
|
||||
|
||||
async void PlayInOrder(string folderPath)
|
||||
{
|
||||
List<Song> songs = new List<Song>();
|
||||
Uri musicUri = MediaStore.Audio.Media.GetContentUriForPath(folderPath);
|
||||
CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null);
|
||||
ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground();
|
||||
|
||||
if (musicCursor != null && musicCursor.MoveToFirst())
|
||||
{
|
||||
int titleID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title);
|
||||
int artistID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Artist);
|
||||
int albumID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album);
|
||||
int thisID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id);
|
||||
int pathID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
|
||||
do
|
||||
{
|
||||
string path = musicCursor.GetString(pathID);
|
||||
|
||||
if (!path.Contains(folderPath))
|
||||
continue;
|
||||
|
||||
string Artist = musicCursor.GetString(artistID);
|
||||
string Title = musicCursor.GetString(titleID);
|
||||
string Album = musicCursor.GetString(albumID);
|
||||
long AlbumArt = musicCursor.GetLong(musicCursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.AlbumId));
|
||||
long id = musicCursor.GetLong(thisID);
|
||||
|
||||
if (Title == null)
|
||||
Title = "Unknown Title";
|
||||
if (Artist == null)
|
||||
Artist = "Unknow Artist";
|
||||
if (Album == null)
|
||||
Album = "Unknow Album";
|
||||
|
||||
songs.Add(new Song(Title, Artist, Album, null, AlbumArt, id, path));
|
||||
}
|
||||
while (musicCursor.MoveToNext());
|
||||
musicCursor.Close();
|
||||
|
||||
songs.Reverse();
|
||||
Browse.act = Activity;
|
||||
Browse.Play(songs[0]);
|
||||
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
foreach (Song song in songs)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetPlaylist(string path)
|
||||
{
|
||||
List<string> playList = new List<string>();
|
||||
|
||||
@@ -9,6 +9,7 @@ using Android.Views;
|
||||
using Android.Widget;
|
||||
using MusicApp.Resources.values;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
@@ -202,15 +203,28 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListAdapter = adapter;
|
||||
}
|
||||
|
||||
private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
|
||||
private async void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
|
||||
{
|
||||
Browse.act = Activity;
|
||||
|
||||
Song item = tracks[e.Position];
|
||||
List<Song> queue = tracks.GetRange(e.Position + 1, tracks.Count - e.Position - 1);
|
||||
if (result != null)
|
||||
{
|
||||
item = result[e.Position];
|
||||
queue = result.GetRange(e.Position + 1, result.Count - e.Position - 1);
|
||||
}
|
||||
queue.Reverse();
|
||||
|
||||
Browse.Play(item);
|
||||
|
||||
while(MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
foreach(Song song in queue)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public override void OnResume()
|
||||
{
|
||||
base.OnResume();
|
||||
if (MainActivity.parcelable != null)
|
||||
if (MainActivity.parcelableSender == "Home" && !MainActivity.instance.ResumeKiller)
|
||||
{
|
||||
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.parcelable);
|
||||
MainActivity.parcelable = null;
|
||||
|
||||
@@ -39,9 +39,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
if(MainActivity.instance.youtubeInstanceSave == null)
|
||||
{
|
||||
MainActivity.instance.FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh).SetEnabled(true);
|
||||
}
|
||||
MainActivity.instance.ToolBar.Visibility = ViewStates.Visible;
|
||||
MainActivity.instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).Visibility = ViewStates.Visible;
|
||||
MainActivity.instance.FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh).SetEnabled(true);
|
||||
MainActivity.instance.ShowSmallPlayer();
|
||||
MainActivity.instance.PrepareSmallPlayer();
|
||||
base.OnDestroy();
|
||||
@@ -296,9 +299,35 @@ namespace MusicApp.Resources.Portable_Class
|
||||
private void Fab_Click(object sender, EventArgs e)
|
||||
{
|
||||
MainActivity.instance.SupportFragmentManager.PopBackStack();
|
||||
MainActivity.instance.ResumeInstance();
|
||||
//OnDestroy();
|
||||
//MainActivity.instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).SelectedItemId = Resource.Id.musicLayout;
|
||||
if (MainActivity.instance.youtubeInstanceSave != null)
|
||||
{
|
||||
int selectedTab = 0;
|
||||
switch (MainActivity.instance.youtubeInstanceSave)
|
||||
{
|
||||
case "YoutubeEngine-All":
|
||||
selectedTab = 0;
|
||||
break;
|
||||
case "YoutubeEngine-Tracks":
|
||||
selectedTab = 1;
|
||||
break;
|
||||
case "YoutubeEngine-Playlists":
|
||||
selectedTab = 2;
|
||||
break;
|
||||
case "YoutubeEngine-Channels":
|
||||
selectedTab = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MainActivity.instance.SetYtTabs(YoutubeEngine.searchKeyWorld, selectedTab);
|
||||
YoutubeEngine.instances[selectedTab].focused = true;
|
||||
YoutubeEngine.instances[selectedTab].OnFocus();
|
||||
YoutubeEngine.instances[selectedTab].ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.instance.youtubeParcel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainActivity.instance.ResumeInstance();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowQueue_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -203,7 +203,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
act.SupportActionBar.Title = playlist.GetName();
|
||||
MainActivity.instance.HideTabs();
|
||||
instance = null;
|
||||
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
||||
if (isEmpty)
|
||||
@@ -230,17 +229,20 @@ namespace MusicApp.Resources.Portable_Class
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
|
||||
builder.SetTitle("Pick an action");
|
||||
if (local)
|
||||
builder.SetItems(new string[] { "Random play", "Rename", "Delete" }, (senderAlert, args) =>
|
||||
builder.SetItems(new string[] { "Play in order", "Random play", "Rename", "Delete" }, (senderAlert, args) =>
|
||||
{
|
||||
switch (args.Which)
|
||||
{
|
||||
case 0:
|
||||
RandomPlay(playlist.GetID(), Activity);
|
||||
PlayInOrder(playlist.GetID());
|
||||
break;
|
||||
case 1:
|
||||
Rename(Position, playlist);
|
||||
RandomPlay(playlist.GetID(), Activity);
|
||||
break;
|
||||
case 2:
|
||||
Rename(Position, playlist);
|
||||
break;
|
||||
case 3:
|
||||
RemovePlaylist(Position, playlist.GetID());
|
||||
break;
|
||||
default:
|
||||
@@ -248,20 +250,23 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
});
|
||||
else
|
||||
builder.SetItems(new string[] { "Random play", "Rename", "Delete", "Download" }, (senderAlert, args) =>
|
||||
builder.SetItems(new string[] { "Play in order", "Random play", "Rename", "Delete", "Download" }, (senderAlert, args) =>
|
||||
{
|
||||
switch (args.Which)
|
||||
{
|
||||
case 0:
|
||||
YoutubeEngine.RandomPlay(playlist.GetPath());
|
||||
PlayInOrder(playlist.GetPath());
|
||||
break;
|
||||
case 1:
|
||||
RenameYoutubePlaylist(Position, playlist.GetPath());
|
||||
YoutubeEngine.RandomPlay(playlist.GetPath());
|
||||
break;
|
||||
case 2:
|
||||
RemoveYoutubePlaylist(Position, playlist.GetPath());
|
||||
RenameYoutubePlaylist(Position, playlist.GetPath());
|
||||
break;
|
||||
case 3:
|
||||
RemoveYoutubePlaylist(Position, playlist.GetPath());
|
||||
break;
|
||||
case 4:
|
||||
YoutubeEngine.DownloadPlaylist(playlist.GetPath());
|
||||
break;
|
||||
default:
|
||||
@@ -271,6 +276,89 @@ namespace MusicApp.Resources.Portable_Class
|
||||
builder.Show();
|
||||
}
|
||||
|
||||
public async void PlayInOrder(long playlistID)
|
||||
{
|
||||
Android.Net.Uri musicUri = Playlists.Members.GetContentUri("external", playlistID);
|
||||
List<Song> songs = new List<Song>();
|
||||
CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null);
|
||||
ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground();
|
||||
|
||||
if (musicCursor != null && musicCursor.MoveToFirst())
|
||||
{
|
||||
int titleID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title);
|
||||
int artistID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Artist);
|
||||
int albumID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album);
|
||||
int thisID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id);
|
||||
int pathID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
|
||||
do
|
||||
{
|
||||
string Artist = musicCursor.GetString(artistID);
|
||||
string Title = musicCursor.GetString(titleID);
|
||||
string Album = musicCursor.GetString(albumID);
|
||||
long AlbumArt = musicCursor.GetLong(musicCursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.AlbumId));
|
||||
long id = musicCursor.GetLong(thisID);
|
||||
string path = musicCursor.GetString(pathID);
|
||||
|
||||
if (Title == null)
|
||||
Title = "Unknown Title";
|
||||
if (Artist == null)
|
||||
Artist = "Unknow Artist";
|
||||
if (Album == null)
|
||||
Album = "Unknow Album";
|
||||
|
||||
songs.Add(new Song(Title, Artist, Album, null, AlbumArt, id, path));
|
||||
}
|
||||
while (musicCursor.MoveToNext());
|
||||
musicCursor.Close();
|
||||
|
||||
songs.Reverse();
|
||||
Browse.act = Activity;
|
||||
Browse.Play(songs[0]);
|
||||
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
foreach(Song song in songs)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void PlayInOrder(string playlistID)
|
||||
{
|
||||
List<Song> songs = new List<Song>();
|
||||
await MainActivity.instance.WaitForYoutube();
|
||||
string nextPageToken = "";
|
||||
while (nextPageToken != null)
|
||||
{
|
||||
var ytPlaylistRequest = YoutubeEngine.youtubeService.PlaylistItems.List("snippet, contentDetails");
|
||||
ytPlaylistRequest.PlaylistId = playlistID;
|
||||
ytPlaylistRequest.MaxResults = 50;
|
||||
ytPlaylistRequest.PageToken = nextPageToken;
|
||||
|
||||
var ytPlaylist = await ytPlaylistRequest.ExecuteAsync();
|
||||
|
||||
foreach (var item in ytPlaylist.Items)
|
||||
{
|
||||
Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, item.ContentDetails.VideoId, -1, -1, item.ContentDetails.VideoId, true);
|
||||
songs.Add(song);
|
||||
}
|
||||
|
||||
nextPageToken = ytPlaylist.NextPageToken;
|
||||
}
|
||||
songs.Reverse();
|
||||
YoutubeEngine.Play(songs[0].youtubeID, songs[0].GetName(), songs[0].GetArtist(), songs[0].GetAlbum());
|
||||
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
foreach (Song song in songs)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RandomPlay(long playlistID, Context context)
|
||||
{
|
||||
List<string> tracksPath = new List<string>();
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
|
||||
float scale = MainActivity.instance.Resources.DisplayMetrics.Density;
|
||||
if (position + 1 == playlistsName.Count)
|
||||
if (position + 1 == playlistsName.Count && ytPlaylists.Count == 2 && ytPlaylists[1]?.GetName() == "EMPTY")
|
||||
{
|
||||
holder.ItemView.SetPadding(0, 0, 0, listPadding);
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holder.more.LayoutParameters;
|
||||
|
||||
@@ -10,6 +10,7 @@ using Android.Widget;
|
||||
using MusicApp.Resources.values;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
@@ -83,6 +84,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
async void PopulateList()
|
||||
{
|
||||
System.Console.WriteLine("&Populating playlist tracks with ydID = " + ytID);
|
||||
if (playlistId == 0 && ytID == "")
|
||||
return;
|
||||
|
||||
@@ -220,12 +222,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
while (musicCursor.MoveToNext());
|
||||
musicCursor.Close();
|
||||
}
|
||||
|
||||
adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, tracks)
|
||||
{
|
||||
listPadding = MainActivity.paddingBot - MainActivity.defaultPaddingBot
|
||||
};
|
||||
ListAdapter = adapter;
|
||||
}
|
||||
else if (ytID != null)
|
||||
{
|
||||
@@ -284,11 +280,16 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListAdapter = adapter;
|
||||
}
|
||||
|
||||
private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
|
||||
private async void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
|
||||
{
|
||||
Song item = tracks[e.Position];
|
||||
List<Song> queue = tracks.GetRange(e.Position + 1, tracks.Count - e.Position - 1);
|
||||
if (result != null && result.Count - 1 >= e.Position)
|
||||
{
|
||||
item = result[e.Position];
|
||||
queue = result.GetRange(e.Position + 1, result.Count - e.Position - 1);
|
||||
}
|
||||
queue.Reverse();
|
||||
|
||||
if (!item.IsYt)
|
||||
{
|
||||
@@ -296,7 +297,17 @@ namespace MusicApp.Resources.Portable_Class
|
||||
Browse.Play(item);
|
||||
}
|
||||
else
|
||||
YoutubeEngine.Play(item.GetPath(), item.GetName(), item.GetArtist(), item.GetAlbum());
|
||||
{
|
||||
YoutubeEngine.Play(item.youtubeID, item.GetName(), item.GetArtist(), item.GetAlbum());
|
||||
}
|
||||
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
foreach (Song song in queue)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public override void OnResume()
|
||||
{
|
||||
base.OnResume();
|
||||
if (MainActivity.parcelable != null)
|
||||
if (MainActivity.parcelableSender == "Queue" && !MainActivity.instance.ResumeKiller)
|
||||
{
|
||||
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.parcelable);
|
||||
MainActivity.parcelable = null;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
await MainActivity.instance.WaitForYoutube();
|
||||
|
||||
SearchResource.ListRequest searchResult = youtubeService.Search.List("snippet");
|
||||
searchResult.Fields = "items(id/videoId,id/kind,snippet/title,snippet/thumbnails/default/url,snippet/channelTitle)";
|
||||
searchResult.Fields = "items(id/videoId,id/playlistId,id/kind,snippet/title,snippet/thumbnails/default/url,snippet/channelTitle)";
|
||||
searchResult.Q = search.Replace(" ", "+-");
|
||||
searchResult.Type = "video";
|
||||
switch (querryType)
|
||||
@@ -157,7 +157,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
foreach(var video in searchReponse.Items)
|
||||
{
|
||||
Song videoInfo = new Song(video.Snippet.Title, video.Snippet.ChannelTitle, video.Snippet.Thumbnails.Default__.Url, video.Id.VideoId, -1, -1, video.Id.VideoId, true);
|
||||
Song videoInfo = new Song(video.Snippet.Title, video.Snippet.ChannelTitle, video.Snippet.Thumbnails.Default__.Url, video.Id.VideoId ?? video.Id.PlaylistId, -1, -1, video.Id.VideoId ?? video.Id.PlaylistId, true);
|
||||
YtKind kind = YtKind.Null;
|
||||
|
||||
switch (video.Id.Kind)
|
||||
@@ -241,12 +241,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
searchView.ClearFocus();
|
||||
searchView.Iconified = true;
|
||||
searchView.SetQuery("", false);
|
||||
AppCompatActivity act = (AppCompatActivity)Activity;
|
||||
act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
act.SupportActionBar.Title = item.GetName();
|
||||
MainActivity.instance.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
MainActivity.instance.SupportActionBar.Title = item.GetName();
|
||||
MainActivity.instance.HideTabs();
|
||||
instances = null;
|
||||
//MainActivity.instance.youtubeParcel = ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + querryType;
|
||||
MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(item.youtubeID, item.GetName()), true);
|
||||
break;
|
||||
case YtKind.Channel:
|
||||
@@ -329,14 +329,25 @@ namespace MusicApp.Resources.Portable_Class
|
||||
intent.PutExtra("youtubeID", videoID);
|
||||
intent.PutExtra("thumbnailURI", thumbnailURL);
|
||||
Android.App.Application.Context.StartService(intent);
|
||||
|
||||
parseProgress.Visibility = ViewStates.Gone;
|
||||
//if(instance != null)
|
||||
//{
|
||||
// MainActivity.parcelable = instance.ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
// MainActivity.parcelableSender = "YoutubeEngine" + "-" + instance.querryType;
|
||||
//}
|
||||
MainActivity.instance.SaveInstance();
|
||||
|
||||
if (instance != null)
|
||||
{
|
||||
MainActivity.instance.youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
|
||||
|
||||
ViewGroup rootView = instance.Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
foreach (YoutubeEngine inst in instances)
|
||||
{
|
||||
MainActivity.instance.OnPaddingChanged -= inst.OnPaddingChanged;
|
||||
rootView.RemoveView(inst.emptyView);
|
||||
}
|
||||
rootView.RemoveView(loadingView);
|
||||
instances = null;
|
||||
}
|
||||
else
|
||||
MainActivity.instance.SaveInstance();
|
||||
|
||||
MainActivity.instance.HideTabs();
|
||||
MainActivity.instance.HideSearch();
|
||||
MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).AddToBackStack(null).Commit();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="No playlist found on this device"
|
||||
android:text="This playlist is empty"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:id="@+id/noPlaylist"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
android:summary="Comming soon" />
|
||||
<Preference
|
||||
android:title="Version :"
|
||||
android:summary="V. 1.3" />
|
||||
android:summary="V. 1.4" />
|
||||
<AccountPreference
|
||||
android:key="account"
|
||||
android:icon="@drawable/ic_account_circle_black_24dp"
|
||||
|
||||
Reference in New Issue
Block a user