Solving some player's bug

This commit is contained in:
Anonymous Raccoon
2018-05-26 20:57:00 +02:00
parent bee90dae39
commit 5650a68637
13 changed files with 186 additions and 189 deletions
+61 -35
View File
@@ -47,8 +47,8 @@ namespace MusicApp
public static int dialogTheme;
public static IParcelable parcelable;
public static string parcelableSender;
public IParcelable youtubeParcel;
public string youtubeInstanceSave;
public static IParcelable youtubeParcel;
public static string youtubeInstanceSave;
public Android.Support.V7.Widget.Toolbar ToolBar;
public bool NoToolbarMenu = false;
@@ -58,6 +58,7 @@ namespace MusicApp
public bool usePager;
public View quickPlayLayout;
public bool HomeDetails = false;
public bool paused = false;
private Handler handler = new Handler();
private ProgressBar bar;
@@ -93,6 +94,7 @@ namespace MusicApp
OnPaddingChanged?.Invoke(this, e);
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
@@ -335,9 +337,34 @@ namespace MusicApp
private async void ActionPlayer()
{
await Task.Delay(100);
//if (YoutubeEngine.instances != null)
//{
// YoutubeEngine instance = null;
// foreach (YoutubeEngine inst in YoutubeEngine.instances)
// {
// Console.WriteLine(inst);
// if (inst.focused)
// instance = inst;
// }
// youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
// youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
// ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
// foreach (YoutubeEngine inst in YoutubeEngine.instances)
// {
// OnPaddingChanged -= inst.OnPaddingChanged;
// rootView.RemoveView(inst.emptyView);
// }
// rootView.RemoveView(YoutubeEngine.loadingView);
// YoutubeEngine.instances = null;
//}
//else
// SaveInstance();
HideTabs();
HideSearch();
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).Commit();
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).AddToBackStack(null).Commit();
}
private async void ReCreateSmallPlayer()
@@ -850,7 +877,6 @@ namespace MusicApp
public void PrepareSmallPlayer()
{
Console.WriteLine("&Index = " + MusicPlayer.CurrentID());
Song current = MusicPlayer.queue[MusicPlayer.CurrentID()];
CoordinatorLayout smallPlayer = FindViewById<CoordinatorLayout>(Resource.Id.smallPlayer);
@@ -954,19 +980,19 @@ namespace MusicApp
}
youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
foreach (YoutubeEngine inst in YoutubeEngine.instances)
{
MainActivity.instance.OnPaddingChanged -= inst.OnPaddingChanged;
OnPaddingChanged -= inst.OnPaddingChanged;
rootView.RemoveView(inst.emptyView);
}
rootView.RemoveView(YoutubeEngine.loadingView);
YoutubeEngine.instances = null;
}
else
MainActivity.instance.SaveInstance();
SaveInstance();
HideTabs();
HideSearch();
@@ -1278,23 +1304,25 @@ namespace MusicApp
return (int) (px * scale + 0.5f);
}
//protected override void OnResume()
//{
// base.OnResume();
protected override void OnResume()
{
base.OnResume();
paused = false;
instance = this;
// 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()
{
@@ -1306,11 +1334,6 @@ namespace MusicApp
parcelableSender = "Home";
parcelable = Home.instance.ListView.GetLayoutManager().OnSaveInstanceState();
}
//else if (Queue.instance != null)
//{
// parcelableSender = "Queue";
// parcelable = Queue.instance.ListView.GetLayoutManager().OnSaveInstanceState();
//}
else if (Browse.instance != null && Browse.instance.focused)
{
parcelableSender = "Browse";
@@ -1325,7 +1348,6 @@ namespace MusicApp
}
else if (Playlist.instance != null)
{
Console.WriteLine("&Playlist saved");
parcelableSender = "Playlist";
parcelable = Playlist.instance.ListView.GetLayoutManager().OnSaveInstanceState();
}
@@ -1340,6 +1362,11 @@ namespace MusicApp
parcelableSender = "FolderTracks";
parcelable = FolderTracks.instance.ListView.OnSaveInstanceState();
}
else
{
parcelableSender = "Home";
parcelable = null;
}
}
public void ResumeInstance()
@@ -1347,24 +1374,17 @@ namespace MusicApp
switch (parcelableSender)
{
case "Home":
//Navigate(Resource.Id.musicLayout, true);
FindViewById<BottomNavigationView>(Resource.Id.bottomView).SelectedItemId = Resource.Id.musicLayout;
break;
//case "Queue":
// Transition(Resource.Id.contentView, Queue.instance, false, true);
// break;
case "Browse":
//Navigate(Resource.Id.browseLayout, true);
FindViewById<BottomNavigationView>(Resource.Id.bottomView).SelectedItemId = Resource.Id.browseLayout;
break;
case "FolderBrowse":
//Navigate(Resource.Id.browseLayout, true);
FindViewById<BottomNavigationView>(Resource.Id.bottomView).SelectedItemId = Resource.Id.browseLayout;
FindViewById<ViewPager>(Resource.Id.pager).CurrentItem = 1;
FindViewById<TabLayout>(Resource.Id.tabs).SetScrollPosition(1, 0f, true);
break;
case "Playlist":
//Navigate(Resource.Id.playlistLayout, true);
FindViewById<BottomNavigationView>(Resource.Id.bottomView).SelectedItemId = Resource.Id.playlistLayout;
break;
case "YoutubeEngine-All":
@@ -1414,5 +1434,11 @@ namespace MusicApp
StartService(intent);
}
}
protected override void OnPause()
{
base.OnPause();
paused = true;
}
}
}
@@ -518,6 +518,7 @@ namespace MusicApp.Resources.Portable_Class
public override void OnResume()
{
base.OnResume();
instance = this;
if(MainActivity.parcelable != null && MainActivity.parcelableSender == "Browse")
{
ListView.OnRestoreInstanceState(MainActivity.parcelable);
@@ -367,5 +367,11 @@ namespace MusicApp.Resources.Portable_Class
albumArt = null;
tempFile = false;
}
protected override void OnResume()
{
base.OnResume();
instance = this;
}
}
}
@@ -457,6 +457,7 @@ namespace MusicApp.Resources.Portable_Class
public override void OnResume()
{
base.OnResume();
instance = this;
if (MainActivity.parcelable != null && MainActivity.parcelableSender == "FolderBrowse")
{
ListView.OnRestoreInstanceState(MainActivity.parcelable);
@@ -24,7 +24,7 @@ namespace MusicApp.Resources.Portable_Class
public string path;
private List<Song> tracks = new List<Song>();
private string[] actions = new string[] { "Play", "Play Next", "Play Last", "Add To Playlist" };
private readonly string[] actions = new string[] { "Play", "Play Next", "Play Last", "Add To Playlist" };
public override void OnActivityCreated(Bundle savedInstanceState)
@@ -285,5 +285,11 @@ namespace MusicApp.Resources.Portable_Class
});
builder.Show();
}
public override void OnResume()
{
base.OnResume();
instance = this;
}
}
}
@@ -354,6 +354,7 @@ namespace MusicApp.Resources.Portable_Class
public override void OnResume()
{
base.OnResume();
instance = this;
if (MainActivity.parcelableSender == "Home" && !MainActivity.instance.ResumeKiller)
{
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.parcelable);
@@ -11,6 +11,7 @@ using Android.Support.V4.Content;
using Android.Support.V4.Media.Session;
using Android.Support.V7.Preferences;
using Android.Support.V7.Widget;
using Android.Views;
using Android.Widget;
using Com.Google.Android.Exoplayer2;
using Com.Google.Android.Exoplayer2.Extractor;
@@ -68,6 +69,14 @@ namespace MusicApp.Resources.Portable_Class
switch (intent.Action)
{
case "YoutubePlay":
string action = intent.GetStringExtra("action");
string title = intent.GetStringExtra("title");
string artist = intent.GetStringExtra("artist");
string thumbnailURL = intent.GetStringExtra("thumbnailURI");
ParseAndPlay(action, file, title, artist, thumbnailURL);
break;
case "Previus":
PlayLast();
break;
@@ -99,34 +108,17 @@ namespace MusicApp.Resources.Portable_Class
break;
case "PlayNext":
string title = intent.GetStringExtra("title");
if (title != null)
{
string artist = intent.GetStringExtra("artist");
string youtubeID = intent.GetStringExtra("youtubeID");
string thumbnailURI = intent.GetStringExtra("thumbnailURI");
AddToQueue(file, title, artist, youtubeID, thumbnailURI);
return StartCommandResult.Sticky;
}
AddToQueue(file);
break;
case "PlayLast":
title = intent.GetStringExtra("title");
if (title != null)
{
string artist = intent.GetStringExtra("artist");
string youtubeID = intent.GetStringExtra("youtubeID");
string thumbnailURI = intent.GetStringExtra("thumbnailURI");
PlayLastInQueue(file, title, artist, youtubeID, thumbnailURI);
return StartCommandResult.Sticky;
}
PlayLastInQueue(file);
break;
case "Stop":
Stop();
break;
case "SleepPause":
SleepPause();
break;
@@ -136,18 +128,7 @@ namespace MusicApp.Resources.Portable_Class
return StartCommandResult.Sticky;
if (file != null)
{
string title = intent.GetStringExtra("title");
if(title != null)
{
string artist = intent.GetStringExtra("artist");
string youtubeID = intent.GetStringExtra("youtubeID");
string thumbnailURI = intent.GetStringExtra("thumbnailURI");
Play(file, title, artist, youtubeID, thumbnailURI);
return StartCommandResult.Sticky;
}
Play(file);
}
return StartCommandResult.Sticky;
}
@@ -241,7 +222,7 @@ namespace MusicApp.Resources.Portable_Class
if(song.queueSlot == -1)
song.queueSlot = CurrentID() + 1;
Console.WriteLine("&QueueSlot = " + song.queueSlot);
Console.WriteLine("&QueueSlot = " + song.queueSlot + "Title = " + song.GetName());
currentID = song.queueSlot;
@@ -253,23 +234,23 @@ namespace MusicApp.Resources.Portable_Class
Player.instance?.RefreshPlayer();
ParseNextSong();
CoordinatorLayout smallPlayer = MainActivity.instance.FindViewById<CoordinatorLayout>(Resource.Id.smallPlayer);
smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = song.GetName();
smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = song.GetArtist();
smallPlayer.FindViewById<ImageView>(Resource.Id.spPlay).SetImageResource(Resource.Drawable.ic_pause_black_24dp);
ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
//CoordinatorLayout smallPlayer = MainActivity.instance.FindViewById<CoordinatorLayout>(Resource.Id.smallPlayer);
//smallPlayer.FindViewById<TextView>(Resource.Id.spTitle).Text = song.GetName();
//smallPlayer.FindViewById<TextView>(Resource.Id.spArtist).Text = song.GetArtist();
//smallPlayer.FindViewById<ImageView>(Resource.Id.spPlay).SetImageResource(Resource.Drawable.ic_pause_black_24dp);
//ImageView art = smallPlayer.FindViewById<ImageView>(Resource.Id.spArt);
if (!song.IsYt)
{
var songCover = Uri.Parse("content://media/external/audio/albumart");
var nextAlbumArtUri = ContentUris.WithAppendedId(songCover, song.GetAlbumArt());
//if (!song.IsYt)
//{
// var songCover = Uri.Parse("content://media/external/audio/albumart");
// var nextAlbumArtUri = ContentUris.WithAppendedId(songCover, song.GetAlbumArt());
Picasso.With(Application.Context).Load(nextAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art);
}
else
{
Picasso.With(Application.Context).Load(song.GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art);
}
// Picasso.With(Application.Context).Load(nextAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art);
//}
//else
//{
// Picasso.With(Application.Context).Load(song.GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art);
//}
}
public void Play(Song song, bool addToQueue = true, long progress = -1)
@@ -367,6 +348,55 @@ namespace MusicApp.Resources.Portable_Class
}
}
private async void ParseAndPlay(string action, string videoID, string title, string artist, string thumbnailURL)
{
if (!parsing)
{
parsing = true;
if (MainActivity.instance != null && action == "Play")
{
ProgressBar parseProgress = MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress);
parseProgress.Visibility = ViewStates.Visible;
parseProgress.ScaleY = 6;
}
YoutubeClient client = new YoutubeClient();
var mediaStreamInfo = await client.GetVideoMediaStreamInfosAsync(videoID);
AudioStreamInfo streamInfo = mediaStreamInfo.Audio.OrderBy(s => s.Bitrate).Last();
switch (action)
{
case "Play":
Play(streamInfo.Url, title, artist, videoID, thumbnailURL);
break;
case "PlayNext":
AddToQueue(streamInfo.Url, title, artist, videoID, thumbnailURL);
parsing = false;
return;
case "PlayLast":
PlayLastInQueue(streamInfo.Url, title, artist, videoID, thumbnailURL);
parsing = false;
return;
}
if (MainActivity.instance != null)
{
MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
if (!MainActivity.instance.paused)
{
MainActivity.instance.HideTabs();
MainActivity.instance.HideSearch();
MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).AddToBackStack(null).Commit();
}
}
parsing = false;
}
}
public async void RandomPlay(List<string> filePath, bool clearQueue)
{
currentID = -1;
@@ -840,7 +870,6 @@ namespace MusicApp.Resources.Portable_Class
queue[fromPosition].queueSlot = fromPosition;
for(int i = 0; i < queue.Count; i++)
{
Console.WriteLine("&CurrentID = " + CurrentID() + " item id = " + queue[i].queueSlot + " i = " + i + "Item name = " + queue[i].GetName());
if (CurrentID() == queue[i].queueSlot)
currentID = i;
+9 -3
View File
@@ -35,7 +35,7 @@ namespace MusicApp.Resources.Portable_Class
public override void OnDestroy()
{
if(MainActivity.instance.youtubeInstanceSave == null)
if(MainActivity.youtubeInstanceSave == null)
{
MainActivity.instance.FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh).SetEnabled(true);
}
@@ -389,10 +389,10 @@ namespace MusicApp.Resources.Portable_Class
private async void Fab_Click(object sender, EventArgs e)
{
MainActivity.instance.SupportFragmentManager.PopBackStack();
if (MainActivity.instance.youtubeInstanceSave != null)
if (MainActivity.youtubeInstanceSave != null)
{
int selectedTab = 0;
switch (MainActivity.instance.youtubeInstanceSave)
switch (MainActivity.youtubeInstanceSave)
{
case "YoutubeEngine-All":
selectedTab = 0;
@@ -468,5 +468,11 @@ namespace MusicApp.Resources.Portable_Class
intent.PutExtra("time", time);
Activity.StartService(intent);
}
public override void OnResume()
{
base.OnResume();
instance = this;
}
}
}
@@ -610,14 +610,13 @@ namespace MusicApp.Resources.Portable_Class
public override void OnResume()
{
base.OnResume();
instance = this;
if (MainActivity.parcelable != null)
{
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.parcelable);
MainActivity.parcelable = null;
MainActivity.parcelableSender = null;
}
if (instance == null)
instance = this;
}
}
}
@@ -448,6 +448,7 @@ namespace MusicApp.Resources.Portable_Class
public override void OnResume()
{
base.OnResume();
instance = this;
if (MainActivity.parcelable != null && MainActivity.parcelableSender == "PlaylistTrack")
{
ListView.OnRestoreInstanceState(MainActivity.parcelable);
@@ -71,6 +71,7 @@ namespace MusicApp.Resources.Portable_Class
protected override void OnDestroy()
{
Player.instance?.UpdateNext();
base.OnDestroy();
instance = null;
}
@@ -208,6 +209,7 @@ namespace MusicApp.Resources.Portable_Class
protected override void OnResume()
{
base.OnResume();
instance = this;
if (MainActivity.parcelableSender == "Queue" && !MainActivity.instance.ResumeKiller)
{
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.parcelable);
@@ -8,7 +8,6 @@ using Google.Apis.YouTube.v3.Data;
using MusicApp.Resources.values;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MusicApp.Resources.Portable_Class
{
@@ -19,8 +19,6 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using TagLib;
using YoutubeExplode;
using YoutubeExplode.Models.MediaStreams;
namespace MusicApp.Resources.Portable_Class
{
@@ -82,9 +80,9 @@ namespace MusicApp.Resources.Portable_Class
while (ListView == null || ListView.GetLayoutManager() == null)
await Task.Delay(10);
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.instance.youtubeParcel);
MainActivity.instance.youtubeInstanceSave = null;
MainActivity.instance.youtubeParcel = null;
ListView.GetLayoutManager().OnRestoreInstanceState(MainActivity.youtubeParcel);
MainActivity.youtubeInstanceSave = null;
MainActivity.youtubeParcel = null;
}
public static Fragment[] NewInstances(string searchQuery)
@@ -258,8 +256,8 @@ namespace MusicApp.Resources.Portable_Class
MainActivity.instance.SupportActionBar.Title = item.GetName();
MainActivity.instance.HideTabs();
instances = null;
MainActivity.instance.youtubeParcel = ListView.GetLayoutManager().OnSaveInstanceState();
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + querryType;
MainActivity.youtubeParcel = ListView.GetLayoutManager().OnSaveInstanceState();
MainActivity.youtubeInstanceSave = "YoutubeEngine" + "-" + querryType;
MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(item.youtubeID, item.GetName(), false), true);
break;
case YtKind.Channel:
@@ -309,29 +307,21 @@ namespace MusicApp.Resources.Portable_Class
builder.Show();
}
public static async void Play(string videoID, string title, string artist, string thumbnailURL, YoutubeEngine instance = null)
public static void Play(string videoID, string title, string artist, string thumbnailURL, YoutubeEngine instance = null)
{
ProgressBar parseProgress = MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress);
parseProgress.Visibility = ViewStates.Visible;
parseProgress.ScaleY = 6;
YoutubeClient client = new YoutubeClient();
var mediaStreamInfo = await client.GetVideoMediaStreamInfosAsync(videoID);
AudioStreamInfo streamInfo = mediaStreamInfo.Audio.OrderBy(s => s.Bitrate).Last();
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
intent.PutExtra("file", streamInfo.Url);
intent.SetAction("YoutubePlay");
intent.PutExtra("action", "Play");
intent.PutExtra("file", videoID);
intent.PutExtra("title", title);
intent.PutExtra("artist", artist);
intent.PutExtra("youtubeID", videoID);
intent.PutExtra("thumbnailURI", thumbnailURL);
Android.App.Application.Context.StartService(intent);
parseProgress.Visibility = ViewStates.Gone;
if (instance != null)
{
MainActivity.instance.youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
MainActivity.instance.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
MainActivity.youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState();
MainActivity.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType;
ViewGroup rootView = instance.Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
foreach (YoutubeEngine inst in instances)
@@ -344,10 +334,6 @@ namespace MusicApp.Resources.Portable_Class
}
else
MainActivity.instance.SaveInstance();
MainActivity.instance.HideTabs();
MainActivity.instance.HideSearch();
MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).AddToBackStack(null).Commit();
}
public static async void PlayFiles(Song[] files)
@@ -373,48 +359,28 @@ namespace MusicApp.Resources.Portable_Class
}
public static async void PlayNext(string videoID, string title, string artist, string thumbnailURL)
public static void PlayNext(string videoID, string title, string artist, string thumbnailURL)
{
ProgressBar parseProgress = MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress);
parseProgress.Visibility = ViewStates.Visible;
parseProgress.ScaleY = 6;
YoutubeClient client = new YoutubeClient();
var mediaStreamInfo = await client.GetVideoMediaStreamInfosAsync(videoID);
AudioStreamInfo streamInfo = mediaStreamInfo.Audio.OrderBy(s => s.Bitrate).Last();
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
intent.SetAction("PlayNext");
intent.PutExtra("file", streamInfo.Url);
intent.SetAction("YoutubePlay");
intent.PutExtra("action", "PlayNext");
intent.PutExtra("file", videoID);
intent.PutExtra("title", title);
intent.PutExtra("artist", artist);
intent.PutExtra("youtubeID", videoID);
intent.PutExtra("thumbnailURI", thumbnailURL);
Android.App.Application.Context.StartService(intent);
parseProgress.Visibility = ViewStates.Gone;
}
public static async void PlayLast(string videoID, string title, string artist, string thumbnailURL)
public static void PlayLast(string videoID, string title, string artist, string thumbnailURL)
{
ProgressBar parseProgress = MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress);
parseProgress.Visibility = ViewStates.Visible;
parseProgress.ScaleY = 6;
YoutubeClient client = new YoutubeClient();
var mediaStreamInfo = await client.GetVideoMediaStreamInfosAsync(videoID);
AudioStreamInfo streamInfo = mediaStreamInfo.Audio.OrderBy(s => s.Bitrate).Last();
Intent intent = new Intent(Android.App.Application.Context, typeof(MusicPlayer));
intent.SetAction("PlayLast");
intent.PutExtra("file", streamInfo.Url);
intent.SetAction("YoutubePlay");
intent.PutExtra("action", "PlayLast");
intent.PutExtra("file", videoID);
intent.PutExtra("title", title);
intent.PutExtra("artist", artist);
intent.PutExtra("youtubeID", videoID);
intent.PutExtra("thumbnailURI", thumbnailURL);
Android.App.Application.Context.StartService(intent);
parseProgress.Visibility = ViewStates.Gone;
}
public async static void Download(string name, string videoID)
@@ -448,52 +414,6 @@ namespace MusicApp.Resources.Portable_Class
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
if (prefManager.GetString("downloadPath", null) != null)
{
//if (!skipExistVerification)
//{
// List<string> downloadedName = new List<string>();
// List<string> downloadedID = new List<string>();
// for (int i = 0; i < names.Length; i++)
// {
// if (FileIsAlreadyDownloaded(videoIDs[i]))
// {
// downloadedName.Add(names[i]);
// downloadedID.Add(videoIDs[i]);
// }
// }
// if (downloadedName.Count > 0)
// {
// List<string> namesList = names.ToList();
// List<string> idList = videoIDs.ToList();
// for(int i = 0; i < downloadedName.Count; i++)
// {
// namesList.Remove(downloadedName[i]);
// idList.Remove(downloadedID[i]);
// }
// names = namesList.ToArray();
// videoIDs = idList.ToArray();
// if (downloadedName.Count == 1)
// {
// Snackbar.Make(MainActivity.instance.FindViewById(Resource.Id.snackBar), downloadedName[0] + " is already on your device.", Snackbar.LengthShort).SetAction("Download this file anyway", (v) =>
// {
// Downloader.instance.Download(new DownloadFile(downloadedName[0], downloadedID[0], playlist));
// }).Show();
// }
// else
// {
// Snackbar.Make(MainActivity.instance.FindViewById(Resource.Id.snackBar), downloadedName.Count + " files are already on your device", Snackbar.LengthShort).SetAction("Download all this files anyway", (v) =>
// {
// for(int i = 0; i < downloadedName.Count; i++)
// Downloader.instance.Download(new DownloadFile(downloadedName[i], downloadedID[i], playlist));
// }).Show();
// }
// }
//}
Toast.MakeText(Android.App.Application.Context, "Downloading...", ToastLength.Short).Show();
Context context = Android.App.Application.Context;
Intent intent = new Intent(context, typeof(Downloader));
@@ -534,7 +454,7 @@ namespace MusicApp.Resources.Portable_Class
try
{
Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
var meta = TagLib.File.Create(new StreamFileAbstraction(path, stream, stream)); //Make app crash if user has midi files ?
var meta = TagLib.File.Create(new StreamFileAbstraction(path, stream, stream));
string ytID = meta.Tag.Comment;
stream.Dispose();
@@ -621,7 +541,7 @@ namespace MusicApp.Resources.Portable_Class
playListId.Add(playlist.Id);
}
Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(context, MainActivity.dialogTheme);
AlertDialog.Builder builder = new AlertDialog.Builder(context, MainActivity.dialogTheme);
builder.SetTitle("Add to a playlist");
builder.SetItems(playList.ToArray(), (senderAlert, args) =>
{