0

Newbie help with Brightscript - crashes and reboots

Hi,

Just starting out in Brightscript, and my first project is to produce a video (multilanguage) with or without subtitles. However, my first script crashes after a few seconds and the unit reboots.

For the moment, I'm just trying to put the time code up on the screen with the video.

debug=false

REM Video resolution to use

VideoResolution$="1920x1080x50p"

REM Create the video player

v=CreateObject("roVideoPlayer")

REM And a container to receive messages

p=createobject("roMessagePort")

v.SetPort(p)

REM Volume of the video

v.SetVolume(100)

REM Subtitle field

subtitle=CreateObject("roTextField",0,750,1920,380,0)

REM Set the resolution

mode = CreateObject("roVideoMode")

mode.SetMode(VideoResolution$)

REM Play the first file

play:

ok=v.PlayFile("English.mp4")

REM Check it has played OK

if ok=0 then

ifdebugthenprint"Playback failed"

gotoplay

endif

loop:

REM Wait for any messages

msg=wait(0,p)

subtitle.Raise()

subtitle.SetCursorPos(0,0)

print #subtitle, v.GetPlaybackPosition()

ifdebugprinttype(msg)

REM Video event

iftype(msg) ="roVideoEvent"then

REM Event 8 is end of media play

ifmsg.GetInt() =8then

gotoplay

endif

endif

REM Waiting loop, forever

goto loop
 
If I remove the subtitle object, then it plays OK.

1 comment

  • 0
    Avatar
    Gerald Holdsworth

    Reply to my own query...I read the width and height of the text box wrong - should be in characters, not pixels. I've also added a bit more (lifted direct from the documentation). So it is now:

    REM Subtitle field
    meta = CreateObject("roAssociativeArray")
    meta.AddReplace("CharWidth", 20)
    meta.AddReplace("CharLength", 32)
    meta.AddReplace("BackgroundColor", &H101010) ' Dark grey
    meta.AddReplace("TextColor", &Hffff00) ' Yellow
    subtitle=CreateObject("roTextField",0,750,96,2,meta)

     

Please sign in to leave a comment.