diff --git a/MusicApp/MainActivity.cs b/MusicApp/MainActivity.cs
index 917f0e6..7966f10 100644
--- a/MusicApp/MainActivity.cs
+++ b/MusicApp/MainActivity.cs
@@ -166,50 +166,6 @@ namespace MusicApp
HttpClientInitializer = credential,
ApplicationName = "MusicApp"
});
-
- //OAuth2Request request = new OAuth2Request("POST"; new Uri())
- //var refreshRequest = new OAuth2Request("POST", new Uri(OAuthSettings.TokenURL), postDictionary, googleAccount);
- //refreshRequest.GetResponseAsync().ContinueWith(task => {
- // if (task.IsFaulted)
- // Console.WriteLine("Error: " + task.Exception.InnerException.Message);
- // else
- // {
- // string json = task.Result.GetResponseText();
- // Console.WriteLine(json);
- // try
- // {
- // << just deserialize the json response, eg. with Newtonsoft>>
- // }
- // catch (Exception exception)
- // {
- // Console.WriteLine("!!!!!Exception: {0}", exception.ToString());
- // Logout();
- // }
- // }
- //});
-
- //await auth.RequestAccessTokenAsync(queryValues).ContinueWith(result =>
- //{
- // Console.WriteLine("Requesting new token from auth api");
- // string accessToken = result.Result["access_token"];
- // string expiresIN = result.Result["expires_in"];
-
- // Console.WriteLine("new acces token: " + accessToken);
- // Console.WriteLine("new expire date: " + expiresIN);
-
- // DateTime expireDate = DateTime.UtcNow.AddSeconds(double.Parse(expiresIN));
- // ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(this);
- // ISharedPreferencesEditor editor = pref.Edit();
- // editor.PutString("expireDate", expireDate.ToString());
- // editor.Apply();
-
- // GoogleCredential credential = GoogleCredential.FromAccessToken(accessToken);
- // YoutubeEngine.youtubeService = new YouTubeService(new BaseClientService.Initializer()
- // {
- // HttpClientInitializer = credential,
- // ApplicationName = "MusicApp"
- // });
- //});
}
@@ -249,16 +205,6 @@ namespace MusicApp
ToolBar = (Android.Support.V7.Widget.Toolbar) FindViewById(Resource.Id.toolbar);
SetSupportActionBar(ToolBar);
SupportActionBar.Title = "MusicApp";
-
- Play();
- }
-
- async void Play()
- {
- YoutubeClient client = new YoutubeClient();
- var videoInfo = await client.GetVideoAsync("ziaf3RrG80U");
- AudioStreamInfo streamInfo = videoInfo.AudioStreamInfos.OrderBy(s => s.Bitrate).Last();
- Console.WriteLine(streamInfo.Url);
}
public override bool OnCreateOptionsMenu(IMenu menu)
diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj
index c1e7c18..e32ca9a 100644
--- a/MusicApp/MusicApp.csproj
+++ b/MusicApp/MusicApp.csproj
@@ -397,6 +397,9 @@
+
+
+
diff --git a/MusicApp/Resources/Portable Class/Adapter.cs b/MusicApp/Resources/Portable Class/Adapter.cs
index af7a5a8..7253288 100644
--- a/MusicApp/Resources/Portable Class/Adapter.cs
+++ b/MusicApp/Resources/Portable Class/Adapter.cs
@@ -24,6 +24,9 @@ namespace MusicApp.Resources.Portable_Class
public override View GetView(int position, View convertView, ViewGroup parent)
{
+ if (position > songList.Count || position < 0)
+ return convertView;
+
if (inflater == null)
{
inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
@@ -49,6 +52,12 @@ namespace MusicApp.Resources.Portable_Class
Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);
}
+
+ if (!songList[position].isParsed)
+ {
+
+ }
+
return convertView;
}
}
diff --git a/MusicApp/Resources/Portable Class/MusicPlayer.cs b/MusicApp/Resources/Portable Class/MusicPlayer.cs
index 90f9cea..67b1427 100644
--- a/MusicApp/Resources/Portable Class/MusicPlayer.cs
+++ b/MusicApp/Resources/Portable Class/MusicPlayer.cs
@@ -36,11 +36,12 @@ namespace MusicApp.Resources.Portable_Class
public NotificationManager notificationManager;
public static bool isRunning = false;
public static string title;
+ private static bool parsing = false;
+ public static int currendID = -1;
private Notification notification;
private const int notificationID = 1000;
-
public override IBinder OnBind(Intent intent)
{
return null;
@@ -310,7 +311,6 @@ namespace MusicApp.Resources.Portable_Class
}
else
{
- Console.WriteLine("Yt song: " + song.GetAlbum());
Picasso.With(Application.Context).Load(song.GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art);
}
}
@@ -333,11 +333,36 @@ namespace MusicApp.Resources.Portable_Class
bar.Progress = (int) player.CurrentPosition;
bar.ProgressChanged += (sender, e) =>
{
+ Console.WriteLine(player.Duration - e.Progress);
if (player != null && e.FromUser)
player.SeekTo(e.Progress);
+
+ if (player != null && player.Duration - e.Progress <= 1500 && player.Duration - e.Progress > 0)
+ ParseNextSong();
};
}
+ public static async void ParseNextSong()
+ {
+ if (CurrentID() + 1 > queue.Count)
+ return;
+
+ Song song = queue[CurrentID() + 1];
+ if (song.isParsed)
+ return;
+
+ if (!song.isParsed && !parsing)
+ {
+ parsing = true;
+ YoutubeClient client = new YoutubeClient();
+ var videoInfo = await client.GetVideoAsync(song.GetPath());
+ AudioStreamInfo streamInfo = videoInfo.AudioStreamInfos.OrderBy(s => s.Bitrate).Last();
+ song.SetPath(streamInfo.Url);
+ song.isParsed = true;
+ parsing = false;
+ }
+ }
+
public static int Duration
{
get
diff --git a/MusicApp/Resources/Portable Class/Player.cs b/MusicApp/Resources/Portable Class/Player.cs
index 0b78236..3e66ab3 100644
--- a/MusicApp/Resources/Portable Class/Player.cs
+++ b/MusicApp/Resources/Portable Class/Player.cs
@@ -232,6 +232,7 @@ namespace MusicApp.Resources.Portable_Class
private void Fab_Click(object sender, EventArgs e)
{
Activity.SupportFragmentManager.BeginTransaction()./*SetCustomAnimations(Resource.Animation.SlideInUp, Resource.Animation.SlideOutUp).*/Replace(Resource.Id.contentView, Queue.NewInstance()).Commit();
+ MainActivity.instance.FindViewById(Resource.Id.bottomView).SelectedItemId = Resource.Id.musicLayout;
}
private void Last_Click(object sender, EventArgs e)
diff --git a/MusicApp/Resources/Portable Class/Playlist.cs b/MusicApp/Resources/Portable Class/Playlist.cs
index e9b9a09..db8a087 100644
--- a/MusicApp/Resources/Portable Class/Playlist.cs
+++ b/MusicApp/Resources/Portable Class/Playlist.cs
@@ -95,7 +95,8 @@ namespace MusicApp.Resources.Portable_Class
if (adapter == null || adapter.Count == 0)
{
isEmpty = true;
- Activity.AddContentView(emptyView, View.LayoutParameters);
+ if(emptyView != null)
+ Activity.AddContentView(emptyView, View.LayoutParameters);
}
}
diff --git a/MusicApp/Resources/Portable Class/PlaylistTracks.cs b/MusicApp/Resources/Portable Class/PlaylistTracks.cs
index 32803b4..67acfb5 100644
--- a/MusicApp/Resources/Portable Class/PlaylistTracks.cs
+++ b/MusicApp/Resources/Portable Class/PlaylistTracks.cs
@@ -9,6 +9,7 @@ using Android.Views;
using Android.Widget;
using MusicApp.Resources.values;
using System.Collections.Generic;
+using System.Linq;
namespace MusicApp.Resources.Portable_Class
{
@@ -23,7 +24,9 @@ namespace MusicApp.Resources.Portable_Class
public bool isEmpty = false;
private List tracks = new List();
- private string[] actions = new string[] { "Play", "Play Next", "Play Last", "Remove Track from playlist" };
+ private List ytTracksIDs = new List();
+ private List ytTracksIdsResult;
+ private string[] actions = new string[] { "Play", "Play Next", "Play Last", "Remove Track from playlist", "Add To Playlist" };
public override void OnActivityCreated(Bundle savedInstanceState)
@@ -118,6 +121,7 @@ namespace MusicApp.Resources.Portable_Class
adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, tracks);
ListAdapter = adapter;
+ ListView.Adapter = adapter;
ListView.TextFilterEnabled = true;
ListView.ItemClick += ListView_ItemClick;
ListView.ItemLongClick += ListView_ItemLongClick;
@@ -133,7 +137,7 @@ namespace MusicApp.Resources.Portable_Class
string nextPageToken = "";
while(nextPageToken != null)
{
- var ytPlaylistRequest = YoutubeEngine.youtubeService.PlaylistItems.List("snippet");
+ var ytPlaylistRequest = YoutubeEngine.youtubeService.PlaylistItems.List("snippet, contentDetails");
ytPlaylistRequest.PlaylistId = ytID;
ytPlaylistRequest.MaxResults = 50;
ytPlaylistRequest.PageToken = nextPageToken;
@@ -142,9 +146,9 @@ namespace MusicApp.Resources.Portable_Class
foreach (var item in ytPlaylist.Items)
{
- Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, -1, -1, item.Id, true);
- System.Console.WriteLine(song.GetName());
+ Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, -1, -1, item.ContentDetails.VideoId, true);
tracks.Add(song);
+ ytTracksIDs.Add(item.Id);
}
nextPageToken = ytPlaylist.NextPageToken;
@@ -152,6 +156,7 @@ namespace MusicApp.Resources.Portable_Class
adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, tracks);
ListAdapter = adapter;
+ ListView.Adapter = adapter;
ListView.TextFilterEnabled = true;
ListView.ItemClick += ListView_ItemClick;
ListView.ItemLongClick += ListView_ItemLongClick;
@@ -167,11 +172,15 @@ namespace MusicApp.Resources.Portable_Class
public void Search(string search)
{
result = new List();
- foreach (Song item in tracks)
+ ytTracksIdsResult = new List();
+ for(int i = 0; i < tracks.Count; i++)
{
+ Song item = tracks[i];
if (item.GetName().ToLower().Contains(search.ToLower()) || item.GetArtist().ToLower().Contains(search.ToLower()))
{
result.Add(item);
+ if (ytID != null)
+ ytTracksIdsResult.Add(ytTracksIDs[i]);
}
}
ListAdapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, result);
@@ -194,6 +203,8 @@ namespace MusicApp.Resources.Portable_Class
private void ListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
{
+ List action = actions.ToList();
+
Song item = tracks[e.Position];
if (result != null)
item = result[e.Position];
@@ -203,10 +214,14 @@ namespace MusicApp.Resources.Portable_Class
Browse.act = Activity;
Browse.inflater = LayoutInflater;
}
+ else
+ {
+ action.Add("Download");
+ }
AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AppCompatAlertDialogStyle);
builder.SetTitle("Pick an action");
- builder.SetItems(actions, (senderAlert, args) =>
+ builder.SetItems(action.ToArray(), (senderAlert, args) =>
{
switch (args.Which)
{
@@ -216,24 +231,43 @@ namespace MusicApp.Resources.Portable_Class
else
YoutubeEngine.Play(item.GetPath());
break;
+
case 1:
if (!item.IsYt)
Browse.PlayNext(item);
else
YoutubeEngine.PlayNext(item.GetPath());
break;
+
case 2:
if (!item.IsYt)
Browse.PlayLast(item);
else
YoutubeEngine.PlayLast(item.GetPath());
break;
+
case 3:
if (!item.IsYt)
RemoveFromPlaylist(item);
else
- YoutubeEngine.RemoveFromPlaylist(item.GetPath(), ytID);
+ {
+ string ytTrackID = ytTracksIDs[e.Position];
+ if (ytTracksIdsResult != null)
+ ytTrackID = ytTracksIdsResult[e.Position];
+
+ YoutubeEngine.RemoveFromPlaylist(ytTrackID);
+ RemoveFromYtPlaylist(item, ytTrackID);
+ }
break;
+
+ case 4:
+ YoutubeEngine.GetPlaylists(item.GetPath(), Activity);
+ break;
+
+ case 5:
+ YoutubeEngine.Download(item.GetName(), item.GetPath());
+ break;
+
default:
break;
}
@@ -241,6 +275,16 @@ namespace MusicApp.Resources.Portable_Class
builder.Show();
}
+ private void RemoveFromYtPlaylist(Song item, string ytTrackID)
+ {
+ tracks.Remove(item);
+ adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, tracks);
+ ListAdapter = adapter;
+ ListView.Adapter = adapter;
+ ytTracksIDs.Remove(ytTrackID);
+ ytTracksIdsResult?.Remove(ytTrackID);
+ }
+
void RemoveFromPlaylist(Song item)
{
ContentResolver resolver = Activity.ContentResolver;
diff --git a/MusicApp/Resources/Portable Class/YoutubeEngine.cs b/MusicApp/Resources/Portable Class/YoutubeEngine.cs
index 44e5fef..649abd5 100644
--- a/MusicApp/Resources/Portable Class/YoutubeEngine.cs
+++ b/MusicApp/Resources/Portable Class/YoutubeEngine.cs
@@ -7,14 +7,14 @@ using Android.Support.V7.App;
using Android.Views;
using Android.Widget;
using Google.Apis.YouTube.v3;
+using Google.Apis.YouTube.v3.Data;
using Java.Util;
using MusicApp.Resources.values;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using YoutubeExplode;
using YoutubeExplode.Models.MediaStreams;
-using System;
-using System.Threading.Tasks;
namespace MusicApp.Resources.Portable_Class
{
@@ -133,7 +133,7 @@ namespace MusicApp.Resources.Portable_Class
PlayLast(item.GetPath());
break;
case 3:
- GetPlaylists(item.GetPath());
+ GetPlaylists(item.GetPath(), Activity);
break;
case 4:
Download(item.GetName(), item.GetPath());
@@ -174,11 +174,11 @@ namespace MusicApp.Resources.Portable_Class
if (files.Length < 2)
return;
- await Task.Delay(10000);
+ await Task.Delay(5000);
for(int i = 1; i < files.Length; i++)
{
- MusicPlayer.queue.Add(files[i]);
+ MusicPlayer.queue.Insert(MusicPlayer.CurrentID() + i, files[i]);
}
}
@@ -236,23 +236,12 @@ namespace MusicApp.Resources.Portable_Class
}
}
- public static void RemoveFromPlaylist(string videoID, string playlistID)
+ public static void RemoveFromPlaylist(string videoID)
{
- HashMap parameters = new HashMap();
- parameters.Put("id", videoID);
- parameters.Put("onBehalfOfContentOwner", "");
-
- PlaylistItemsResource.DeleteRequest deleteRequest = youtubeService.PlaylistItems.Delete(playlistID);
- if (parameters.ContainsKey("onBehalfOfContentOwner") && parameters.Get("onBehalfOfContentOwner").ToString() != "")
- {
- deleteRequest.OnBehalfOfContentOwner = parameters.Get("onBehalfOfContentOwner").ToString();
- }
-
- deleteRequest.Execute();
+ youtubeService.PlaylistItems.Delete(videoID).Execute();
}
-
- public static async void GetPlaylists(string videoID)
+ public static async void GetPlaylists(string videoID, Context context)
{
if (MainActivity.instance.TokenHasExpire())
{
@@ -264,19 +253,144 @@ namespace MusicApp.Resources.Portable_Class
}
List playList = new List();
- List playListId = new List();
+ List playListId = new List();
playList.Add("Create a playlist");
- playListId.Add(0);
+ playListId.Add("newPlaylist");
-
- //AlertDialog.Builder builder = new AlertDialog.Builder(act, Resource.Style.AppCompatAlertDialogStyle);
- //builder.SetTitle("Add to a playlist");
- //builder.SetItems(playList.ToArray(), (senderAlert, args) =>
- //{
- // AddToPlaylist(item, playList[args.Which], playListId[args.Which]);
- //});
- //builder.Show();
+ HashMap parameters = new HashMap();
+ parameters.Put("part", "snippet,contentDetails");
+ parameters.Put("mine", "true");
+ parameters.Put("maxResults", "25");
+ parameters.Put("onBehalfOfContentOwner", "");
+ parameters.Put("onBehalfOfContentOwnerChannel", "");
+
+ PlaylistsResource.ListRequest ytPlaylists = youtubeService.Playlists.List(parameters.Get("part").ToString());
+
+ if (parameters.ContainsKey("mine") && parameters.Get("mine").ToString() != "")
+ {
+ bool mine = (parameters.Get("mine").ToString() == "true") ? true : false;
+ ytPlaylists.Mine = mine;
+ }
+
+ if (parameters.ContainsKey("maxResults"))
+ {
+ ytPlaylists.MaxResults = long.Parse(parameters.Get("maxResults").ToString());
+ }
+
+ if (parameters.ContainsKey("onBehalfOfContentOwner") && parameters.Get("onBehalfOfContentOwner").ToString() != "")
+ {
+ ytPlaylists.OnBehalfOfContentOwner = parameters.Get("onBehalfOfContentOwner").ToString();
+ }
+
+ if (parameters.ContainsKey("onBehalfOfContentOwnerChannel") && parameters.Get("onBehalfOfContentOwnerChannel").ToString() != "")
+ {
+ ytPlaylists.OnBehalfOfContentOwnerChannel = parameters.Get("onBehalfOfContentOwnerChannel").ToString();
+ }
+
+ PlaylistListResponse response = await ytPlaylists.ExecuteAsync();
+
+ for (int i = 0; i < response.Items.Count; i++)
+ {
+ Google.Apis.YouTube.v3.Data.Playlist playlist = response.Items[i];
+ playList.Add(playlist.Snippet.Title);
+ playListId.Add(playlist.Id);
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context, Resource.Style.AppCompatAlertDialogStyle);
+ builder.SetTitle("Add to a playlist");
+ builder.SetItems(playList.ToArray(), (senderAlert, args) =>
+ {
+ AddToPlaylist(videoID, playListId[args.Which], context);
+ });
+ builder.Show();
+ }
+
+ public static void AddToPlaylist(string videoID, string playlistID, Context context)
+ {
+ if(playlistID == "newPlaylist")
+ {
+ AlertDialog.Builder builder = new AlertDialog.Builder(context, Resource.Style.AppCompatAlertDialogStyle);
+ builder.SetTitle("Playlist name");
+ View view = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.CreatePlaylistDialog, null);
+ builder.SetView(view);
+ builder.SetNegativeButton("Cancel", (senderAlert, args) => { });
+ builder.SetPositiveButton("Create", (senderAlert, args) =>
+ {
+ NewPlaylist(view.FindViewById(Resource.Id.playlistName).Text, videoID);
+ });
+ builder.Show();
+ }
+ else
+ {
+ HashMap parameters = new HashMap();
+ parameters.Put("part", "snippet");
+ parameters.Put("onBehalfOfContentOwner", "");
+
+ PlaylistItem playlistItem = new PlaylistItem();
+ PlaylistItemSnippet snippet = new PlaylistItemSnippet();
+ snippet.PlaylistId = playlistID;
+ ResourceId resourceId = new ResourceId();
+ resourceId.Kind = "youtube#video";
+ resourceId.VideoId = videoID;
+ snippet.ResourceId = resourceId;
+ playlistItem.Snippet = snippet;
+
+ var insertRequest = youtubeService.PlaylistItems.Insert(playlistItem, parameters.Get("part").ToString());
+
+ if (parameters.ContainsKey("onBehalfOfContentOwner") && parameters.Get("onBehalfOfContentOwner").ToString() != "")
+ {
+ insertRequest.OnBehalfOfContentOwner = parameters.Get("onBehalfOfContentOwner").ToString();
+ }
+
+ insertRequest.Execute();
+ }
+ }
+
+ public static void NewPlaylist(string playlistName, string videoID)
+ {
+ HashMap parameters = new HashMap();
+ parameters.Put("part", "snippet,status");
+ parameters.Put("onBehalfOfContentOwner", "");
+
+
+ Google.Apis.YouTube.v3.Data.Playlist playlist = new Google.Apis.YouTube.v3.Data.Playlist();
+ PlaylistSnippet snippet = new PlaylistSnippet();
+ PlaylistStatus status = new PlaylistStatus();
+ snippet.Title = playlistName;
+ playlist.Snippet = snippet;
+ playlist.Status = status;
+
+ var createRequest = youtubeService.Playlists.Insert(playlist, parameters.Get("part").ToString());
+
+ if (parameters.ContainsKey("onBehalfOfContentOwner") && parameters.Get("onBehalfOfContentOwner").ToString() != "")
+ {
+ createRequest.OnBehalfOfContentOwner = parameters.Get("onBehalfOfContentOwner").ToString();
+ }
+
+ Google.Apis.YouTube.v3.Data.Playlist response = createRequest.Execute();
+
+ parameters = new HashMap();
+ parameters.Put("part", "snippet");
+ parameters.Put("onBehalfOfContentOwner", "");
+
+ PlaylistItem playlistItem = new PlaylistItem();
+ PlaylistItemSnippet snippetItem = new PlaylistItemSnippet();
+ snippetItem.PlaylistId = response.Id;
+ ResourceId resourceId = new ResourceId();
+ resourceId.Kind = "youtube#video";
+ resourceId.VideoId = videoID;
+ snippetItem.ResourceId = resourceId;
+ playlistItem.Snippet = snippetItem;
+
+ var insertRequest = youtubeService.PlaylistItems.Insert(playlistItem, parameters.Get("part").ToString());
+
+ if (parameters.ContainsKey("onBehalfOfContentOwner") && parameters.Get("onBehalfOfContentOwner").ToString() != "")
+ {
+ insertRequest.OnBehalfOfContentOwner = parameters.Get("onBehalfOfContentOwner").ToString();
+ }
+
+ insertRequest.Execute();
}
}
}
\ No newline at end of file
diff --git a/MusicApp/Resources/Portable Class/YtPlaylists.cs b/MusicApp/Resources/Portable Class/YtPlaylists.cs
index a56cb3b..0a62bed 100644
--- a/MusicApp/Resources/Portable Class/YtPlaylists.cs
+++ b/MusicApp/Resources/Portable Class/YtPlaylists.cs
@@ -120,8 +120,9 @@ namespace MusicApp.Resources.Portable_Class
playlists.Add(song);
}
- Adapter ytAdapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, playlists);
- ListAdapter = ytAdapter;
+ adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, playlists);
+ ListAdapter = adapter;
+ ListView.Adapter = adapter;
ListView.ItemClick += ListView_ItemClick;
ListView.ItemLongClick += ListView_ItemLongClick;
}
@@ -170,7 +171,7 @@ namespace MusicApp.Resources.Portable_Class
string nextPageToken = "";
while (nextPageToken != null)
{
- var ytPlaylistRequest = YoutubeEngine.youtubeService.PlaylistItems.List("snippet");
+ var ytPlaylistRequest = YoutubeEngine.youtubeService.PlaylistItems.List("snippet, contentDetails");
ytPlaylistRequest.PlaylistId = playlistID;
ytPlaylistRequest.MaxResults = 50;
ytPlaylistRequest.PageToken = nextPageToken;
@@ -179,13 +180,14 @@ namespace MusicApp.Resources.Portable_Class
foreach (var item in ytPlaylist.Items)
{
- Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, -1, -1, item.Id, true, false);
+ System.Console.WriteLine(item.Snippet.Title);
+ Song song = new Song(item.Snippet.Title, "", item.Snippet.Thumbnails.Default__.Url, -1, -1, item.ContentDetails.VideoId, true, false);
tracks.Add(song);
}
nextPageToken = ytPlaylist.NextPageToken;
}
-
+ System.Console.WriteLine("All tracks are retrived");
YoutubeEngine.PlayFiles(tracks.ToArray());
}
@@ -205,11 +207,16 @@ namespace MusicApp.Resources.Portable_Class
void RenamePlaylist(int position, string name, string playlistID)
{
+ Google.Apis.YouTube.v3.Data.Playlist playlist = new Google.Apis.YouTube.v3.Data.Playlist();
+ playlist.Snippet = YtPlaylists[position].Snippet;
+ playlist.Snippet.Title = name;
+ playlist.Id = playlistID;
+
YtPlaylists[position].Snippet.Title = name;
- YoutubeEngine.youtubeService.Playlists.Update(YtPlaylists[position], "snippet/title").Execute();
+ YoutubeEngine.youtubeService.Playlists.Update(playlist, "snippet").Execute();
playlists[position].SetName(name);
- ListAdapter = new ArrayAdapter(Android.App.Application.Context, Resource.Layout.PlaylistList, playlists);
+ adapter.NotifyDataSetChanged();
if (ListAdapter.Count == 0)
{
isEmpty = true;
@@ -232,7 +239,10 @@ namespace MusicApp.Resources.Portable_Class
deleteRequest.Execute();
playlists.RemoveAt(position);
- ListAdapter = new ArrayAdapter(Android.App.Application.Context, Resource.Layout.PlaylistList, playlists);
+ YtPlaylists.RemoveAt(position);
+ adapter = new Adapter(Android.App.Application.Context, Resource.Layout.SongList, playlists);
+ ListAdapter = adapter;
+ ListView.Adapter = adapter;
if (ListAdapter.Count == 0)
{
isEmpty = true;
diff --git a/MusicApp/Resources/Resource.Designer.cs b/MusicApp/Resources/Resource.Designer.cs
index 58db043..7ea5d3e 100644
--- a/MusicApp/Resources/Resource.Designer.cs
+++ b/MusicApp/Resources/Resource.Designer.cs
@@ -2360,26 +2360,26 @@ namespace MusicApp
// aapt resource value: 0x7f020053
public const int avd_hide_password = 2130837587;
- // aapt resource value: 0x7f020083
- public const int avd_hide_password_1 = 2130837635;
-
// aapt resource value: 0x7f020084
- public const int avd_hide_password_2 = 2130837636;
+ public const int avd_hide_password_1 = 2130837636;
// aapt resource value: 0x7f020085
- public const int avd_hide_password_3 = 2130837637;
+ public const int avd_hide_password_2 = 2130837637;
+
+ // aapt resource value: 0x7f020086
+ public const int avd_hide_password_3 = 2130837638;
// aapt resource value: 0x7f020054
public const int avd_show_password = 2130837588;
- // aapt resource value: 0x7f020086
- public const int avd_show_password_1 = 2130837638;
-
// aapt resource value: 0x7f020087
- public const int avd_show_password_2 = 2130837639;
+ public const int avd_show_password_1 = 2130837639;
// aapt resource value: 0x7f020088
- public const int avd_show_password_3 = 2130837640;
+ public const int avd_show_password_2 = 2130837640;
+
+ // aapt resource value: 0x7f020089
+ public const int avd_show_password_3 = 2130837641;
// aapt resource value: 0x7f020055
public const int design_bottom_navigation_item_background = 2130837589;
@@ -2454,70 +2454,73 @@ namespace MusicApp
public const int ic_playlist_add_white_24dp = 2130837612;
// aapt resource value: 0x7f02006d
- public const int ic_skip_next_black_24dp = 2130837613;
+ public const int ic_query_builder_black_24dp = 2130837613;
// aapt resource value: 0x7f02006e
- public const int ic_skip_previous_black_24dp = 2130837614;
+ public const int ic_skip_next_black_24dp = 2130837614;
// aapt resource value: 0x7f02006f
- public const int ic_timer_white_24dp = 2130837615;
+ public const int ic_skip_previous_black_24dp = 2130837615;
// aapt resource value: 0x7f020070
- public const int MusicIcon = 2130837616;
+ public const int ic_timer_white_24dp = 2130837616;
// aapt resource value: 0x7f020071
- public const int navigation_empty_icon = 2130837617;
+ public const int MusicIcon = 2130837617;
// aapt resource value: 0x7f020072
- public const int noAlbum = 2130837618;
+ public const int navigation_empty_icon = 2130837618;
// aapt resource value: 0x7f020073
- public const int notification_action_background = 2130837619;
+ public const int noAlbum = 2130837619;
// aapt resource value: 0x7f020074
- public const int notification_bg = 2130837620;
+ public const int notification_action_background = 2130837620;
// aapt resource value: 0x7f020075
- public const int notification_bg_low = 2130837621;
+ public const int notification_bg = 2130837621;
// aapt resource value: 0x7f020076
- public const int notification_bg_low_normal = 2130837622;
+ public const int notification_bg_low = 2130837622;
// aapt resource value: 0x7f020077
- public const int notification_bg_low_pressed = 2130837623;
+ public const int notification_bg_low_normal = 2130837623;
// aapt resource value: 0x7f020078
- public const int notification_bg_normal = 2130837624;
+ public const int notification_bg_low_pressed = 2130837624;
// aapt resource value: 0x7f020079
- public const int notification_bg_normal_pressed = 2130837625;
+ public const int notification_bg_normal = 2130837625;
// aapt resource value: 0x7f02007a
- public const int notification_icon_background = 2130837626;
-
- // aapt resource value: 0x7f020081
- public const int notification_template_icon_bg = 2130837633;
-
- // aapt resource value: 0x7f020082
- public const int notification_template_icon_low_bg = 2130837634;
+ public const int notification_bg_normal_pressed = 2130837626;
// aapt resource value: 0x7f02007b
- public const int notification_tile_bg = 2130837627;
+ public const int notification_icon_background = 2130837627;
+
+ // aapt resource value: 0x7f020082
+ public const int notification_template_icon_bg = 2130837634;
+
+ // aapt resource value: 0x7f020083
+ public const int notification_template_icon_low_bg = 2130837635;
// aapt resource value: 0x7f02007c
- public const int notify_panel_notification_icon_bg = 2130837628;
+ public const int notification_tile_bg = 2130837628;
// aapt resource value: 0x7f02007d
- public const int PlaylistPlay = 2130837629;
+ public const int notify_panel_notification_icon_bg = 2130837629;
// aapt resource value: 0x7f02007e
- public const int PlaylistPlayIcon = 2130837630;
+ public const int PlaylistPlay = 2130837630;
// aapt resource value: 0x7f02007f
- public const int search = 2130837631;
+ public const int PlaylistPlayIcon = 2130837631;
// aapt resource value: 0x7f020080
- public const int settings = 2130837632;
+ public const int search = 2130837632;
+
+ // aapt resource value: 0x7f020081
+ public const int settings = 2130837633;
static Drawable()
{
diff --git a/MusicApp/Resources/drawable/ic_query_builder_black_24dp.png b/MusicApp/Resources/drawable/ic_query_builder_black_24dp.png
new file mode 100644
index 0000000..284de8d
Binary files /dev/null and b/MusicApp/Resources/drawable/ic_query_builder_black_24dp.png differ