public List <Track> Load(bool append, bool restore = false) { string path = InternalStorageHelper.InternalPlaylistAllLocation; System.IO.Directory.CreateDirectory(path); using (IXmlParsable parser = new JsonPlaylistParser(path, "All.json")) { List <Track> tracks = null; if (!append) { tracks = JsonCacheParser.Read(); } if (tracks == null) { List <Paths> songs = SearchForSongs(); if (restore) { if (System.IO.File.Exists(Path.Combine(path, "All.json"))) { File.Delete(Path.Combine(path, "All.json")); } } parser.AddItems(songs); tracks = TrackFinder.ConvertPathsToTracks(songs); CacheSongs(tracks); } return(tracks); } }
/// <summary> /// Finds the full url for the (probably partially specified url) /// for the media file url, using the media path and /// user input if necessary. /// </summary> /// <param name="track"></param> /// <returns></returns> public string Find(Track track) { List <string> places = new List <string> { MediaPath }; string path = TrackFinder.Find(track.Url, places); //before returning the path, check if found, otherwise request user input, if not found successfully if (!File.Exists(path)) { //request user input path = OnFileMissing(track.Name); if (!File.Exists(path)) //still not found? { throw new FileNotFoundException(String.Format("Media file for track {0} not found", track.Name)); } } //we now have the best guess about where that media file is, so save it here if (!track.Url.Equals(path)) //we have now found a location that is different to what we first knew? { //use this one from now on with this track. track.Url = path; } return(path); }
/// <summary> /// Finds the full url for the (probably partially specified url) /// for the media file url, using the media path. /// </summary> /// <param name="track"></param> /// <returns></returns> public override String Find(Track track) { List <string> places = new List <string> { MediaPath, Url }; //first use the specified media path, but as backup also the place where the compliation is stored string path = TrackFinder.Find(track.Url, places); //we now have the best guess about where that media file is, so save it here if (!track.Url.Equals(path)) //we have now found a location that is different to what we first knew? { //use this one from now on with this track. track.Url = path; } return(path); }
/// <summary> /// Finds the full url for the (probably partially specified url) /// for the media file url, using the media path. /// </summary> /// <param name="track"></param> /// <returns></returns> public override String Find(Track track) { var places = new List <string> { MediaPath }; string path = TrackFinder.Find(track.Url, places); //we now have the best guess about where that media file is, so save it here if (!track.Url.Equals(path)) //we have now found a location that is different to what we first knew? { //use this one from now on with this track. track.Url = path; } return(path); }
public void SetTrack(string uri) { var trackFinder = new TrackFinder(); var returnedTrack = trackFinder.GetTrackInfo(uri); ProgressbarValue = 0; _downloadStatus.Clear(); if (returnedTrack != null) { Track = returnedTrack; } else { DownloadStatus = "Ett problem uppstod när information om låten skulle hämtas. Prova med en annan låt."; Track = new Track(); } }
public override String Find(Track track) { var places = new List <string> { MediaPath }; string path = TrackFinder.Find(track.Url, places); //before returning the path, check if found, otherwise request user input, if not found successfully if (!File.Exists(path)) { throw new FileNotFoundException("Media file not found"); } //we now have the best guess about where that media file is, so save that path here if (!track.Url.Equals(path)) //we have now found a location that is different to what we first knew? { //use this one from now on with this track. track.Url = path; } return(path); }
private List <Paths> SearchForSongs() { string[] filters; char[] specialChars; using (IXmlParsable parser = new XmlFilterParser(InternalStorageHelper.InternalXmlFileLocation + "/FiltersAndSpecialChars")) { XmlFilterParser.RVal data = (XmlFilterParser.RVal)parser.FetchItems(); filters = data.filters; specialChars = data.specialChars; } List <Track> tracksFromSD = new List <Track>(); bool hasSd = false; try { tracksFromSD = TrackFinder.GetListOfTracksFromSD(Context, filters, specialChars); hasSd = true; } catch (NotMountedException e) { ISharedPreferences prefs = Context.GetSharedPreferences(Notification_Settings.Root, FileCreationMode.Private); if (prefs.GetBoolean(Notification_Settings.ErrorNotKey, true)) { using (var style = new Android.Support.V7.App.NotificationCompat.BigTextStyle()) { using (Android.Support.V7.App.NotificationCompat.Builder builder = new Android.Support.V7.App.NotificationCompat.Builder(Context)) { using (Android.Support.V4.App.NotificationCompat.Builder not = builder .SetSmallIcon(Resource.Drawable.Logo).SetContentTitle("No SD card found!").SetContentText(e.Message) .SetPriority((int)NotificationPriority.Min).SetStyle(style.BigText(e.Message)) .SetVibrate(new long[] { 1000, 1000, 1000, 1000 })) { var notificationManager = (NotificationManager)Context.GetSystemService(Context.NotificationService); notificationManager.Notify(0, not.Build()); } } } } } List <Track> tracks = new List <Track>(); try { tracks = TrackFinder.GetListOfTracksFromPhone(Context); } catch (Exception ex) { ((Activity)Context).RunOnUiThread(() => { Toast.MakeText(Context, ex.Message, ToastLength.Long).Show(); }); } if (hasSd) { tracks = tracks.Union(tracksFromSD).ToList(); } List <Paths> paths = new List <Paths>(); foreach (var track in tracks) { paths.Add(new Paths() { Path = track.Path, Title = track.FullTitle }); } return(paths); }