Forum Discussion

PositivePeak's avatar
15 years ago

Looping Video

Hi all-

Pardon my newness, but is there a simple script that will launch a video from the first click (no categories - right into video) and loop it over and over until the user hits the back key? I would be willing to pay someone for a simple brs file.

Thanks- I hope all is having a great weekend.

Dave

6 Replies

  • The simplevideoplayer example in the SDK does pretty much exactly that.
  • The simplevideoplayer should be full screen. Are you sure you're looking at it and not the customvideoplayer example?
  • You are right - I was looking at the custom vid example. Thank you. This example looks more toward our needs, however, when you launch this channel- it first goes to a 'play' poster... then, after instructed to play, it will fire off a video. After the video it returns to the poster. My question for you is, how can I get it to restart the same video when it finishes playing and also get it to play as soon as you enter the channel?
  • Here you go... give this a try. All you should need to do is change the videoContent information to match yours:

    Sub RunUserInterface()
    'Draw black canvas to prevent screen flickering between loops
    blackCanvas = CreateObject( "roImageCanvas" )
    blackCanvas.SetLayer( 0, { Color: "#000000", TargetRect: { x: 0, y: 0, w: 1280, h: 720 } } )
    blackCanvas.Show()

    ' Set up video content
    videoContent = {
    Title: "My Video",
    Stream: { url: "http://url.to.my.video" },
    StreamFormat: "mp4"
    }

    ' Create MessagePort for capturing events
    msgPort = CreateObject( "roMessagePort" )

    StartVideo:
    ' create video screen and set the message port
    video = CreateObject( "roVideoScreen" )
    video.SetMessagePort( msgPort)

    ' Set the content, and show the video
    video.SetContent( videoContent )
    video.Show()

    While True
    msg = Wait( 0, video.GetMessagePort() )
    If Type( msg ) = "roVideoScreenEvent" Then
    If msg.IsFullResult() Then
    ' Full Result indicates that the video completed,
    ' So create a new video screen and start again
    GoTo StartVideo
    Else If msg.IsPartialResult() Then
    ' A partial result indicates that the video was
    ' cancelled, probably by pressing up on the remote
    ' so exit the app
    Exit While
    End If
    End If
    End While
    End Sub


    I got your email, btw, but haven't really had a chance to take a look, yet.

    DISCLAIMER: I wrote this in notepad and didn't test it, so there may be a syntax error or two... 😉