Search code examples
rokubrightscript

roImageCanvas layer is not updating


I am working on a custom windowed video player. The functionality that I want is to show a now loading image on top of (or instead of) video player when player is buffering the video and remove the now loading image when player starts to play the video.

But the problem is once now loading image is drawn on the screen it is not going away when player starts to play the video.

Here is the code that I am using to draw the canvas:

function draw_canvas()
m.canvas.AllowUpdates(false)
m.canvas.Clear()
m.canvas.SetLayer(0, m.canvasLayers.background)
if m.isLoadingVideo = true
    m.canvas.SetLayer(1, [m.canvasLayers.frameImage, m.canvasLayers.nowLoadingImage])
else if m.isLoadingVideo = false
    m.canvas.SetLayer(1, [m.canvasLayers.frameImage])
end if
m.canvas.AllowUpdates(true)
end function

Here is the code that calls this draw_canvas function in the event loop:

if type(msg) = "roVideoPlayerEvent"
    if msg.GetMessage() = "start of play"
        m.isLoadingVideo = false
        m.drawCanvas()
    else if msg.GetMessage() = "startup progress"
        if m.isLoadingVideo <> true
            m.isLoadingVideo = true
            m.drawCanvas()
        end if
    end if
end if

roVideoPlayer starts to work with the start of application and is located at the same coordinates as now loading image.

And here is code from my controller function:

m.drawCanvas()
m.videoPlayer.Play()
return m.eventLoop()

I am not able to locate the bug in the code so if anyone can help me with it please???


Solution

  • Found the problem! problem was in my background layer, I hadn't set the CompositionMode to "Source" in the background layer. and the problem vanished after doing so....

    irInStoreScreen.canvasLayers.background = {
        Color: "#00000000",
        targetRect: {
            x: 0,
            y: 0,
            w: irInStoreScreen.screenRect.w,
            h: irInStoreScreen.screenRect.h
        },
        compositionMode: "Source"
    }