Forum Discussion

ojo1's avatar
ojo1
Reel Rookie
5 years ago
Solved

Start live channel with timeshift at live position

Hello,

I've not found any documentation nor trick to proper start streaming a Dash video with timeshift at its live position.
Currently I observe stream duration then seek to that duration for this but it causes an unwanted audio video glitch.

Any help please?

Sample code:

sub init()
  videocontent = createObject("RoSGNode", "ContentNode")

  videocontent.live = true
  videocontent.title = "Live video with timeshift"
  videocontent.streamformat = "dash"
  videocontent.url = "https://host/live/channel_with_2h_timeshift.mpd"

  video = m.top.findNode("exampleVideo")
  video.ObserveField("duration", "onDuration")
  video.content = videocontent

  video.setFocus(true)
  video.control = "play"
end sub

sub onDuration(message as object)
  video = message.getRoSGNode()
  duration = video.duration
  if duration > 10 then
    video.UnobserveField("duration")
    video.seek = duration
  end if
end sub

 

  • Hi ojo1,

    To start at the live edge, you can use the Video node's PlayStart field. In this case, you can do something like this: 

    PlayStart(some large number) (for example, PlayStart(9999)

    The media player will figure out that the live edge is wanted and will automatically set itself to 30 seconds behind it (this is the default setting for smooth buffering and no re-buffering events).

5 Replies

  • RokuJonathanD's avatar
    RokuJonathanD
    Community Moderator

    Hi ojo1,

    To start at the live edge, you can use the Video node's PlayStart field. In this case, you can do something like this: 

    PlayStart(some large number) (for example, PlayStart(9999)

    The media player will figure out that the live edge is wanted and will automatically set itself to 30 seconds behind it (this is the default setting for smooth buffering and no re-buffering events).

    • ojo1's avatar
      ojo1
      Reel Rookie

      Thanks you!

      The documentation talks about negative value to allows "the media players to start playbacks distanced from the edge of the live stream". This is confusing...

      Actually I found that solution after having accidentally put a bookmark position to a live stream!

      Regards

      • Moriarty's avatar
        Moriarty
        Reel Rookie

        ojo1  I did put the playerStart to a big number like said in the previous comment. But, still, the live playback is starting only from 20 seconds behind !!. Any idea what could cause that issue ??

    • nthingvall's avatar
      nthingvall
      Channel Surfer

      RokuJonathanD You said 30 seconds is the default setting for live distance. Is there a way to change this setting? I'm looking through the docs but can't find anything for adjusting that. Even getting within 20 seconds of live edge would make a big difference for me. I'd like to get even closer, but I have a 30 second DVR window and Roku is barely staying within the window the manifest provides. PlayStart and seek have not worked at all because of this distance from live. Thanks!