Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The stop() method is not working for HLS videos in roVideoPlayer #395

Open
lvcabral opened this issue Nov 7, 2024 · 0 comments
Open

The stop() method is not working for HLS videos in roVideoPlayer #395

lvcabral opened this issue Nov 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lvcabral
Copy link
Owner

lvcabral commented Nov 7, 2024

Using the code below if the application does not close, the video will keep playing in the background.
This happens only on the second video of the playlist.

sub demoHLS()
    print "starting video tests"
    rect = {x: 249, y: 177, w: 391, h: 291}
    if m.mainScreen <> invalid and m.port <> invalid
        port = m.port
        screen = m.mainScreen
    else
        port = createObject("roMessagePort")
        screen = createObject("roScreen", true, m.rect.w, m.rect.h)
        screen.setMessagePort(port)
    end if
    screen.setAlphaEnable(false)
    player = CreateObject("roVideoPlayer")
    player.setMessagePort(port)
    player.setLoop(true)
    player.setPositionNotificationPeriod(1)
    player.setDestinationRect(rect)
    player.setContentList([{
        Stream: {url: "https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8"}
        StreamFormat: "hls"
    },{
        Stream: {url: "https://5b44cf20b0388.streamlock.net:8443/vod/smil:hls-maudios-prod.smil/playlist.m3u8"}
        StreamFormat: "hls"
    },{
        Stream: {url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"}
        StreamFormat: "mp4"
	}])
    position = 0
    skip = 15
    tracks = []
    currAudioTrack = 0
    paused = false
    screen.clear(&hFFFFFFFF)
    screen.drawRect(rect.x, rect.y, rect.w, rect.h, 0)
    screen.swapBuffers()
    player.Play()
    while true
        msg = wait(0, port)
        if msg <> invalid
            'If this is a startup progress status message, record progress
            'and update the UI accordingly:
            if type(msg) = "roVideoPlayerEvent" and msg.isStatusMessage()
                print msg.GetMessage(), msg.getIndex()
                'Playback progress (in seconds):
            else if type(msg) = "roVideoPlayerEvent" and msg.isPlaybackPosition()
                position = msg.GetIndex()
                print position
            else if type(msg) = "roVideoPlayerEvent" and msg.isStreamStarted()
                tracks = player.getAudioTracks()
                print tracks.count(); " audio tracks available."
            else if type(msg) = "roUniversalControlEvent"
                index = msg.GetInt()
                print "Remote button pressed: " + index.tostr()
                if index = 0 '<BACK>
                    player.pause()
                    exit while
                else if index = 2 '<UP
                    screen.drawRect(0, 0, 1280, 720, 0)
                    player.SetDestinationRect(0, 0, 0, 0) 'fullscreen
                    screen.swapBuffers()
                else if index = 3 'DOWN
                    screen.clear(&hFFFFFFFF)
                    screen.drawRect(rect.x, rect.y, rect.w, rect.h, 0)
                    player.setDestinationRect(rect)
                    screen.swapBuffers()
                else if index = 4 or index = 8 '<LEFT> or <REV>
                    if position > skip
                        position = position - skip
                        player.Seek(position * 1000)
                    end if
                else if index = 5 or index = 9 '<RIGHT> or <FWD>
                    position = position + skip
                    player.Seek(position * 1000)
                else if index = 10 or index = 6 'INFO or OK
                    if tracks.count() > 0
                        currAudioTrack = (currAudioTrack + 1) mod tracks.count()
                        print "Switching to audio track: "; tracks[currAudioTrack].Language
                        player.ChangeAudioTrack(tracks[currAudioTrack].Track)
                    end if
                else if index = 13 '<PAUSE/PLAY>
                    if paused player.Resume() else player.Pause()
                end if
            else if msg.isPaused()
                paused = true
                print "video paused"
            else if msg.isResumed()
                paused = false
                print "video resumed"
            end if
        end if
    end while
    player.stop()
    player.clearContent()
    screen.setAlphaEnable(true)
end sub
@lvcabral lvcabral added the bug Something isn't working label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant