private void UpdateLastPlayed() { if (book_track != null && book_track.IsPlaying && ServiceManager.PlayerEngine.CurrentState == PlayerState.Playing) { bookmark = GetLastPlayedBookmark (book_track.AlbumId) ?? new Bookmark (); bookmark.Type = LAST_PLAYED_BOOKMARK; bookmark.CreatedAt = DateTime.Now; bookmark.Track = book_track; bookmark.Position = TimeSpan.FromMilliseconds ((int)ServiceManager.PlayerEngine.Position); bookmark.Save (); if (CurrentViewBook != null && book_track.AlbumId == CurrentViewBook.DbId) { book_view.Contents.UpdateResumeButton (bookmark); } } }
internal void UpdateResumeButton (Bookmark bookmark) { if (bookmark != null) { resume_button.LabelWidget.Markup = String.Format ( "<b>{0}</b>\n<small>{1}</small>", GLib.Markup.EscapeText (Catalog.GetString ("Resume Playback")), GLib.Markup.EscapeText (bookmark.Name) ); } else { resume_button.LabelWidget.Markup = String.Format ( "<b>{0}</b>\n<small>{1}</small>", GLib.Markup.EscapeText (Catalog.GetString ("No Bookmark Set")), ""); } }
public void AddBookmark (Bookmark bookmark) { if (select_items.ContainsKey (bookmark)) return; bookmarks.Add (bookmark); if (bookmarks.Count == 1) { bookmark_menu.Append (separator); remove_item.Sensitive = true; } // Add menu item to jump to this bookmark ImageMenuItem select_item = new ImageMenuItem (bookmark.Name.Replace ("_", "__")); select_item.Image = new Image (Stock.JumpTo, IconSize.Menu); select_item.Activated += delegate { bookmark.JumpTo (); }; bookmark_menu.Append (select_item); select_items[bookmark] = select_item; // Add menu item to remove this bookmark ImageMenuItem rem = new ImageMenuItem (bookmark.Name.Replace ("_", "__")); rem.Image = new Image (Stock.Remove, IconSize.Menu); rem.Activated += delegate { bookmark.Remove (); RemoveBookmark (bookmark); }; remove_menu.Append (rem); remove_items[bookmark] = rem; bookmark_map[rem] = bookmark; bookmark_menu.ShowAll (); }
private void RemoveBookmark (Bookmark bookmark) { if (!remove_items.ContainsKey (bookmark)) return; bookmark_menu.Remove (select_items[bookmark]); remove_menu.Remove (remove_items[bookmark]); bookmarks.Remove (bookmark); select_items.Remove (bookmark); bookmark_map.Remove (remove_items[bookmark]); remove_items.Remove (bookmark); if (bookmarks.Count == 0) { bookmark_menu.Remove (separator); remove_item.Sensitive = false; } }
private void HandleNewBookmark (object sender, EventArgs args) { var track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo; if (track != null) { try { var bookmark = new Bookmark (track, (int)ServiceManager.PlayerEngine.Position); if (loaded) { AddBookmark (bookmark); } } catch (Exception e) { Log.Exception ("Unable to Add New Bookmark", e); } } }