Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    7

    Help with Plugin - How to report track position (time) from ProtocolHandler

    I'm have a ProtocolHandler based on IO::Handle and I'm using sysread to deliver data.

    I need to be able to indicate the position within the data stream so LMS displays the proper time as playback occurs.

    I'm hoping I can do that from the getMetadataFor subroutine, but I don't know what to call or how to report the position in the data.

    Can someone tell me how to tell LMS that the data it's playing is "at 3:30" for example?

    Thanks,

    Alex

  2. #2
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,904
    Quote Originally Posted by littla View Post
    I'm have a ProtocolHandler based on IO::Handle and I'm using sysread to deliver data.

    I need to be able to indicate the position within the data stream so LMS displays the proper time as playback occurs.

    I'm hoping I can do that from the getMetadataFor subroutine, but I don't know what to call or how to report the position in the data.

    Can someone tell me how to tell LMS that the data it's playing is "at 3:30" for example?

    Thanks,

    Alex
    Do you really need to set the position or is this more the duration / start offset? Michael will probably give a better answer, but to my knowledge, and this is what I'm using in my ShairTunes2W mods, in getMetadataFor
    Code:
    $client->streamingSong->duration( XX )
    $client->playingSong()->startOffset( XX} );
    $song->track->secs( XX ) ;
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  3. #3
    Junior Member
    Join Date
    Nov 2014
    Posts
    7
    Phillipe,

    That worked. Thanks!

    Unfortunately I only asked one thing out of several I need help on, so let me explain what I'm trying to do...

    I'm trying to make a plugin to play a stream of data, but the stream comes from another server (non-HTTP). The server lets me fetch the audio data (10 seconds per chunk) but the byte size varies. Further I can ask the server to seek to a position (which is approximate). These audio files are usually 2-3 hours long each, so seeking to 30/60/90 minutes in is essential because people won't listen to the entire 2 hours at one sitting.

    I'd like to be able to be told when the user clicked on the track seek bar and get the information about when they'd like to seek to.

    Then I can tell the server when I want to seek to.

    Then I'll need to tell LMS that the buffer of chunks I've fed it through the sysread call needs to be dropped and not delivered to a player (hopefully that can be done).

    Does that make sense?

    If you or anyone else can help me with the other tasks, I'd really appreciate it.
    Last edited by littla; 2017-01-20 at 12:45.

  4. #4
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    14,666
    Look in other plugins for use of the canSeek (which tells LMS that plugin will allow seeking) and getSeekData which is called by LMS to give the plugin the time offset clicked by user - Stream is then restarted so plugin can then use the offset data so usually playing stream is stopped by LMS.
    Last edited by bpa; 2017-01-20 at 14:01.

  5. #5
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,904
    Quote Originally Posted by littla View Post
    Phillipe,

    That worked. Thanks!

    Unfortunately I only asked one thing out of several I need help on, so let me explain what I'm trying to do...

    I'm trying to make a plugin to play a stream of data, but the stream comes from another server (non-HTTP). The server lets me fetch the audio data (10 seconds per chunk) but the byte size varies. Further I can ask the server to seek to a position (which is approximate). These audio files are usually 2-3 hours long each, so seeking to 30/60/90 minutes in is essential because people won't listen to the entire 2 hours at one sitting.

    I'd like to be able to be told when the user clicked on the track seek bar and get the information about when they'd like to seek to.

    Then I can tell the server when I want to seek to.

    Then I'll need to tell LMS that the buffer of chunks I've fed it through the sysread call needs to be dropped and not delivered to a player (hopefully that can be done).

    Does that make sense?

    If you or anyone else can help me with the other tasks, I'd really appreciate it.
    Quote Originally Posted by bpa View Post
    Look in other plugins for use of the canSeek (which tells LMS that plugin will allow seeking) and getSeekData which is called by LMS to give the plugin the time offset clicked by user - Stream is then restarted so plugin can then use the offset data so usually playing stream is stopped by LMS.
    As bpa said, you will find the solution in other plugins. On my side, I did exactly what you describe in the YouTube and Pluzz plugins, and I think bpa did that as well probably in the BBCiPlayer
    Last edited by philippe_44; 2017-01-20 at 14:22.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  6. #6
    Junior Member
    Join Date
    Nov 2014
    Posts
    7

    I spoke too soon...

    Unfortunately, the solution is not working for me after all...

    I am playing a stream (infinite) but it has metadata for songs throughout it. I will know the position within a song and the song's duration as well as the track/artist/album.

    I'd like to update all of this information in the getMetadata handler... unfortunately, it seems that the following does not work.

    my $position = 20; # For debugging, real value comes from HTTP request
    my $duration = 80; # For debugging, real value comes from HTTP request

    $client->playingSong()->startOffset($position);
    $song->track->secs($position);
    $song->duration($duration);

    This does NOT update the duration properly, and the position eventually reads as the duration (I'm assuming something knows how long the stream has been playing and truncates the position at the duration even though it doesn't display the duration properly.

    Also, the metadata on the player area does get updated with new title/artist/album, but the netadata for the queue entry does not.

    What am I doing wrong? Can anyone point me in the right direction?

    Thanks.

  7. #7
    Junior Member
    Join Date
    Nov 2014
    Posts
    7

    For those reading along...

    I may have figured out what I need and thought I'd post for anyone in the future needing what I needed...

    In the getMetadata I'm doing the following:
    1) Record previous duration : my $previous_duration = $song->duration()
    2) Recording the real stream position : my $position_in_seconds = $client->songElapsedSeconds()
    3) Setting the new duration of the track : $song->duration($duration) # $duration comes from HTTP fetch of metadata
    4) Checking if duration has changed, indicating the track has changed and I have to "reset" the song position.
    5) When necessary (see #4) reset the song position : $song->startOffset(-$position_in_seconds);

    This is what I'm using at present and it seems to be getting the job done for me. Hope it helps someone else.

Tags for this Thread

Posting Permissions

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