Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 19 12311 ... LastLast
Results 1 to 10 of 187
  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    102

    New plugin for audio bookmarks

    (Update: Changed text to reflect updates
    (Update: Changed repository because google code is shutting down)


    There is already a plugin for Bookmarks from KDF (http://code.google.com/p/kdfplugins/downloads/list) , but this is unmaintained now for a couple of years and doesn't work on newer players (i. e. Radio or Touch).

    I always wanted a feature like this because i listen a lot to radio dramas / audio books and it's always a pain to find the position where you stopped listening days ago.
    So finally i decided to write a new plugin for a bookmarking feature. Since there had been a couple of posts in this forum where users asked for "audio bookmarks", i post it here - perhaps it can be useful for others too.

    The code is based on the "What was that tune?" plugin from mherger (http://forums.slimdevices.com/showth...+was+that+tune) - thanks for that really handy tool and all the other work you do for the squeezebox system.

    There are some distinct differences:

    • "BookmarkHistory" only works with local music, not with internet streams (this is by design, as i use the album-id to identify the currently played album)
    • It keeps track of the tracknumber and the position in a track of an album you listen to (independent of the player you use)
    • Albums are automatically removed from the bookmark list when you reach the end of the last track (remember: this is for setting bookmarks, not for storing favourites)


    It works automatically:

    • In the settings of the plugin you select the genres for which bookmarks should be used.
    • If you play an album with a matching genre the plugin will keep track of the tracknumber and the position in the track while the album is played.
    • The bookmarked albums are listed in the plugin menu (most recent at the top). Klicking on an album will load the album and start it at the bookmarked position.


    Context menus
    There are also context menus entries for "Now Playing", "Album Info" and "Track Info" if an album has a bookmark:

    • "Remove bookmark": Removes the bookmark. If the album is in the current playlist of the player, it is removed from there (to prevent that it is immediately created again if still playing the album)
    • "Start album from beginning": Resets the bookmark to the start of the first track of the album and replaces the current playlist with the album


    "Prebooking"

    Another feature is the "Prebooking" of a bookmark. If an album has no bookmark i add the entry "Add bookmark to listen later" to the context menus "Now Playing", "Album/Track info".

    This creates a bookmark for the beginning of the first track of the album. These "prebooked" bookmarks are listed at the bottom of the bookmark list (if you use the default sorting).
    Once you listen to the album the "prebooked" bookmark becomes a real one and it is listed at the top.

    The idea is that if you really would like to listen to the critically acclaimed three hour long feature about the sound of the night breeze in the sahara desert, but at this moment you're more in the mood for a crime story, you can "prebook" the bookmark to remind you that you should listen to this sometime later.
    Of course you can also remove such preboooked bookmarks with the context menu...

    Bookmarks for playlists

    Bookmarks are now also applied to playlists. This means that if you play a playlist, the plugin monitors the currently played track and waits for a track that has a genre matching the ones defined in the genre filter. It then adds a bookmark for the playlist and not for the album.

    These "playlist bookmarks" are always named with the name of the playlist. In the bookmarks list i always prepend them with the word "Playlist" (to make them easily distinguishable from album bookmarks).
    Bookmarks of playlists and albums are completely independant of each other. If you play an album it's bookmark will be updated. If you play a playlist, the bookmark of the playlist will be updated.

    "Freezing" a bookmark

    I added a feature to "freeze" a bookmark with the "Now playing" context menu. If you mark a bookmark as "frozen" it is no longer updated when you play the album. It is also not deleted when the last track of an album is played. Useful if you like to listen to audio books before falling asleep.
    You can both "freeze" und "unfreeze" a bookmark from the context menu.

    Bookmarks for remote tracks

    The plugin can also set bookmarks for remote tracks. Please note that these bookmarks are managed differently from the ones for local albums.

    They are not set automatically, so the genre filter does not apply to them. If you want to bookmark a remote track, album or playlist then click in the "Now Playing" context menu on "Add bookmark for current Playlist"
    The plugin then saves the current playlist. By default settings it will load and start this playlist immediatly - unfortunately this will cause a few seconds for rebuffering.
    Reloading the playlist is necessary (otherwise i would not be able to track the progress of the playlist).

    If you prefer to set the bookmark immediatly before you want to stop listening you can uncheck the box "Continue playing after adding a bookmark" in the settings. The plugin will then empty the current playlist after it saved the bookmark.

    The bookmarks for remote tracks are always named like the album that is currently played. The associated saved playlist is removed automatically when the bookmark is removed.

    Please note that these bookmarks are only tracked if you start the playback from the bookmark menu.
    And of course jumping to the correct position in the track requires the stream to be seekable (I tested it with Qobuz, Spotify und Youtube)

    Installation


    • Install the plugin from the list of "3rd party plugins".
    • Check the plugin configuration: The settings are self explanatory. You should at least define a value for the genre filter or the plugin will also be used for music albums (which presumably you don't want) . The filter is a list of comma separated keywords - only albums in which the genre contains one of the keywords are used for bookmarking.
    • I recommend to use a distinctly higher value for the "Threshold" setting than the value of "Precision" (i. e. 15 for threshold and 2 for precision, or 30 for threshold and 4 for precision)
    • Should there be a performance impact (which i think is unlikely) you could always use a higher value for precision. This defines how often the routine which updates a bookmark is called while playing an album.



    If you want player specific bookmarks then please check the configuration setting "Players which keep their own bookmarks"
    Please note:

    1) All existing bookmarks will no longer be visible for these clients
    2) All other clients will see the same bookmarks as before
    3) If you later remove a client from this list, the specific bookmarks for this player will be deleted and the player will see the common bookmarks for all players
    If you enter one or more players (separated by comma) in this option then these players will keep their own bookmarks. So these players can keep and track separate bookmarks for the same album.

    I also added an option to show an additional menu after selecting a bookmark (Setting: "Show additional menu before playing a bookmark"). If you check this option clicking on a bookmark does no longer immediately start playing the album. Instead you will get a menu with the following options:
    • Play
    • Freeze/Unfreeze bookmark
    • Start album from beginning
    • Remove bookmark




    If bookmarks for audio files are useful for you, please give it a try and let me know if you find bugs (i am sure there are some)

    Please note that i am by no means an experienced squeezebox developer and i usually don't write code in Perl, so expect some bugs. Anyway, i have tested this with
    • recent 7.9 nightly build server - but it should also work with older versions
    • Radio, Receiver (and iPeng on an iPod touch) as clients
    • iPeng, Squeezepad as controller apps on iPod and iPad, Squeeze Control on Android


    and it works quite well for me.

    If you are using something like the "KidsPlay" Plugin and you want to use macros...

    The plugin supplies some CLI commands. In the post #48 in this thread you will find an example of how to use this for a single button operation of a Squeezebox Radio:
    https://forums.slimdevices.com/showt...l=1#post865785



    The repository for the plugin is
    Code:
    http://mjohnen.bplaced.net/repo/repo.xml
    Last edited by sternenjaeger; 2020-03-06 at 16:35. Reason: Finally mentioned the bookmark for remote albums in the description

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,776

    New plugin for audio bookmarks

    Nice! This might become something quite a few people have been waiting
    for: keep track of where you were in audiobooks, podcasts etc.

    > Installation:


    Did you consider setting up a repository file on some web server to
    allow installation through the plugin manager? This would simplify
    installation a great deal.

    A few ideas:

    > - Rewind and next buttons wont work for bookmarked albums (because
    > these also trigger the newsong event which then jumps back to the
    > bookmarked position). You can, however, use the scroll bar.


    You could listen to the button command notification and set some flag or
    reset state when fwd/rew are pressed?

    > - Because the plugin uses the album_id's to identify an album the
    > bookmarks will be wiped when you perform a "Full rescan" of the
    > database


    You could use the urlhash value instead. This would only change if a
    file or folder changed.

    --

    Michael

  3. #3
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,793
    Quote Originally Posted by mherger View Post
    Nice! This might become something quite a few people have been waiting
    for: keep track of where you were in audiobooks, podcasts etc.
    Yep. Me, for example! A big thumbs up to you, sternenjaeger!

    One thing I wonder about.... Did you register CLI commands for the plugin? Would there be a way to determine whether there's a bookmark for a certain album? I think I might like to try to play from a bookmark instead of from the first track whenever you play a whole album in iPeng and a bookmark is present.

    Also, it could be useful to register an entry for an album context menu which does exactly that.

    > - Rewind and next buttons wont work for bookmarked albums (because
    > these also trigger the newsong event which then jumps back to the
    > bookmarked position). You can, however, use the scroll bar.[/color]

    You could listen to the button command notification and set some flag or
    reset state when fwd/rew are pressed?
    Hm, but what about people selecting a track in the playlist or whenever the skip command is used instead of the button? I think using these old button commands is really bad style, shouldn't they be mapped to the skip command internally anyway? Is there a way to intercept that one?

    You could use the urlhash value instead. This would only change if a
    file or folder changed.
    Would that also work for remote albums (from services)?
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,776

    New plugin for audio bookmarks

    >>> - Rewind and next buttons wont work for bookmarked albums (because
    >>> these also trigger the newsong event which then jumps back to the
    >>> bookmarked position). You can, however, use the scroll bar.

    >>
    >> You could listen to the button command notification and set some flag or
    >> reset state when fwd/rew are pressed?
    >>

    > Hm, but what about people selecting a track in the playlist or whenever
    > the skip command is used instead of the button? I think using these old
    > button commands is really bad style, shouldn't they be mapped to the
    > skip command internally anyway? Is there a way to intercept that one?[/color]

    skip doesn't exist, does it? There are player jump/index commands. But
    they're not exactly the same: the button code has some additional logic
    built in to behave like you would the actual button expect to behave. It
    doesn't always skip back, but would first jump to the start of the
    current track etc. IMHO it totally makes sense and is still being used
    for the software buttons, too (Touch, web UI).

    >> You could use the urlhash value instead. This would only change if a
    >> file or folder changed.

    >
    > Would that also work for remote albums (from services)?


    oops... meant to write urlmd5 (not urlhash). No, we don't store it for
    remote albums. But you could use url in any case. Uses a few more byte
    than the urlmd5 hash, but that shouldn't hurt too badly in this use case.

    --

    Michael

  5. #5
    Senior Member
    Join Date
    Oct 2012
    Posts
    102
    Nice! This might become something quite a few people have been waiting
    for: keep track of where you were in audiobooks, podcasts etc.
    Thanks!
    Did you consider setting up a repository file on some web server to
    allow installation through the plugin manager? This would simplify
    installation a great deal.
    I didn't plan to, because this is just a small leisure time thing i wrote during christmas holidays. It was only when i finally had it ready and saw that it was better working than i exptected, that i got the idea to post it here. But sure, why not.

    I'll also try to implement you're other suggestions. Could take a couple of days, now that i'am unfortunately back to work and spare time is limited again.

  6. #6
    Senior Member
    Join Date
    Oct 2012
    Posts
    102
    Yep. Me, for example! A big thumbs up to you, sternenjaeger!
    Thank you! Getting feedback from two of the senior developers in the squeezeserver community is something i hadn't expected.

    One thing I wonder about.... Did you register CLI commands for the plugin? Would there be a way to determine whether there's a bookmark for a certain album? I think I might like to try to play from a bookmark instead of from the first track whenever you play a whole album in iPeng and a bookmark is present.
    No, this plugin is just a basic utility: It stores the bookmark information (tracknumber and position in track) in a hash array in it's preferences file.

    The way it works is quite simpel:
    • The plugin menu lists the stored bookmarks. If the user clicks on a bookmark it issues a "playlistcontrol cmd:load" command, which starts the album at the tracknumber stored in the bookmark
    • It subscribes to the "newsong" event that checks the album and tracknumber of the new song and - if there is a bookmark - it issues the "time" command to jump to the correct position (also stored in the bookmark hash entry).
    • The "newsong" event also independently sets up a timer for a routine which queries the "songinfo" for all active players and creates or updates the bookmarks. This routine repeats the timer until no player is in status "playing" anymore


    I'll try to continue working on it. But this is actually just my second plugin (and the first was an even far more simpel thing), so i don't think i am the right man for the job. But we'll see...

    Also, it could be useful to register an entry for an album context menu which does exactly that.
    Good idea, i give it a shot. Although: I find that getting into writing code for the squeezeserver environment is not easy, even if you're used to write code. I had trouble to find documentation and, coming more from the Python/Java side, writing code in Perl for me feels like having to wrestle with an alien beast.

    Once again: Thanks to you and mherger for this friendly feedback. I am using the squeezebox server for a couple of years now but just recently got the idea to write code for it. Perhaps i should have started much earlier - the open architecture of this server is like an invitation to play around with it. But then: I already have more than enough unfinished code in my day job

  7. #7
    Senior Member
    Join Date
    Oct 2012
    Posts
    102
    Following the suggestion from mherger i have setup a repository for the "Bookmark History" plugin. The URL of the repository is
    Code:
    http://bookmarkhistory.googlecode.com/svn/repo.xml
    It still only works will local albums and it is only useful for albums which are audio books or radio dramas - it releases you from the effort of scrolling through an 2 hours long track to find the position where you last stopped listening.
    I tried to improve it a bit:

    • Rewind button now works for bookmarked tracks of an album.
    • I am using the file url now to keep track of the bookmarks, so they are no longer affected by rescans or changes in tags (this also means that the albums no longer need to have correct tag numbers. In this case the bookmark follows the given sort order of the squeezeserver).
    • The plugin subscribes now to the playlist addtrack/loadtracks events. If you play an album which has a bookmark from "My music" it will look through the playlist and (hopefully ) jump to the bookmarked track and position in track. In other words: The bookmark positioning works not only from the menu of the plugin but also from the "regular" squeezeserver menus.


    I am using it now for a couple of days and it's pretty useful for me
    Please let me know if you find errors or you have suggestions for new features.

  8. #8
    Senior Member
    Join Date
    Jul 2009
    Location
    USA
    Posts
    147
    This looks great!

    I'm installing it now, but I'm getting this error:
    [15-01-16 12:31:17.1139] Slim::Utils::PluginManager::load (377) Warning: Couldn't call Plugins::BookmarkHistory::Plugin->initPlugin: Not a HASH reference at /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins/BookmarkHistory/Plugin.pm line 906.

    Also, is there a way to select all generes, maybe like a wildcard "*"?

  9. #9
    Senior Member
    Join Date
    Oct 2012
    Posts
    102
    Quote Originally Posted by rpress View Post
    I'm installing it now, but I'm getting this error:
    [15-01-16 12:31:17.1139] Slim::Utils::PluginManager::load (377) Warning: Couldn't call Plugins::BookmarkHistory::Plugin->initPlugin: Not a HASH reference at /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins/BookmarkHistory/Plugin.pm line 906.

    Also, is there a way to select all generes, maybe like a wildcard "*"?
    Sorry, my fault - i didn't test the repo on a fresh install. I need some time to setup a seperate "clean" squeezeserver, but i think i got it anyway. Could you try again please?

    If you would like to use it for all album genres (just because i am curious: Even for music?) you can leave the genre filter empty. But you should not set the maximum number of bookmarks too high - they are stored in the preferences file of the plugin as simple perl hashes. Could slow down the server if you keep thousands of bookmarked tracks.

    Please let me know if the fresh install works now (otherwise the repo would be completely pointless ).
    Last edited by sternenjaeger; 2015-01-16 at 18:09.

  10. #10
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,776

    New plugin for audio bookmarks

    > Code:
    > --------------------
    > http://bookmarkhistory.googlecode.com/svn/repo.xml
    > --------------------


    Please include the version number in the download file
    (bookmarkhistory.zip). Otherwise people might run into issues getting
    stale, cached versions.

    I'll include it with the main repo asap.

    --

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •