Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gobigwheel
Channel Surfer

Trickplay fields loop not working

I am trying to get a video to loop but it's not looping. I am using the custom-playback-channel-master sample code. I see on https://developer.roku.com/docs/references/scenegraph/media-playback-nodes/video.md under Trickplay fields that loop should "If set to true, the video or video playlist (if the contentIsPlaylist field is set to true to enable video playlists) will be restarted from the beginning after the end is reached." Below is my code. Please let me know what I am doing wrong.

 

'Main Scene Initialization with menu and video.
sub init()
  m.player = m.top.FindNode("Video")
  m.list = m.top.FindNode("MenuList")
  m.player.setFocus(true)

  'Set the initial video player to some content'
  content = CreateObject("roSGNode", "ContentNode")
  content.url = "https://clayton-retail-interface.s3.amazonaws.com/test.mp4"
  content.streamformat = "mp4"
  m.itemfocused = 1
  m.player.content = content
  m.player.loop = true
  'Tell the video player to play the content'
  m.player.control = "play"
end sub

Here is the link to the original github: https://github.com/rokudev/samples/blob/6c939323740a7708919c94431f90844f445b929c/channel%20templates...

Thank you

 

0 Kudos
2 REPLIES 2
gobigwheel
Channel Surfer

Re: Trickplay fields loop not working

For anyone trying to do this here is the solution:

sub init()
  m.player = m.top.FindNode("Video")
  m.list = m.top.FindNode("MenuList")
  m.player.setFocus(true)

  'Set the initial video player to some content'
  m.content = CreateObject("roSGNode", "ContentNode")
  m.content.url = "https://clayton-retail-interface.s3.amazonaws.com/claytonretail.mp4"
  m.content.streamformat = "mp4"
  m.itemfocused = 1
  m.player.content = m.content
  m.player.observeField("state", "videoStateChange")
  m.player.loop = true
  'Tell the video player to play the content'
  m.player.control = "play"
end sub

sub videoStateChange()
  ?"m.player.state==>"m.player.state
  if m.player.state = "finished" or m.player.state = "error"
    m.player.control = "stop"
    m.player.content = m.content
    m.player.control = "play"
  end if

end sub
0 Kudos
renojim
Community Streaming Expert

Re: Trickplay fields loop not working

Thanks for posting your solution, but after looking at the documentation I don't think your setting m.player.loop to true is really doing anything.  From the documentation:

"Both the Audio and Video nodes support the use of playlists, which are lists of several media items to play in sequence rather than a single media item. If a playlist is used, setting the loop field to true causes the entire playlist to play again after the last item in the playlist completes."

It looks to me that loop only affects playlists.  I'd say your solution is fine, but you might want to see if setting up a playlist with one entry would allow you to eliminate your observer.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos