Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

Rovideoplayer and roimagecanvas

Hi All,

I am trying to implement a custom video player. Could someone please point me to some code created for the video player scrubber and play and pause buttons.

Any help would be highly appreciated.

Thanks in advance.

Regards,
Prajwal
0 Kudos
2 Replies
NewManLiving
Level 7

Re: Rovideoplayer and roimagecanvas

I not aware of any example that provides all three requirements. The pause and resume is pretty simple just create your images that look like the remote and issue the pause and resume commands. Use a Boolean flag to keep the state. You would set the players current state by setting a flag in the message that is generated by the command itself. The pause command generates IsPaused, the resume command generates IsResumed. The scrubber would be a slider control that you would have to implement yourself. One way is to use 2 layered rectangles. The one on the bottom would represent your total length. It could be any length that is pleasing to you. The one one the top rides over the bottom one as a percentage of the bottom. As the user user presses the remote buttons you redraw the top rectangle according to the increment that you set. This would advance or rewind the slider control anywhere from 0 to 100 percent of the slider length. Since a percent is a percent you can multiply this percent value times the total duration (getplaybackduration) of the video. Convert this to milliseconds and issue the seek command. You can get elaborate like I do and show the actual time changing as the slider moves so that the user not only can visually see where about in the video he is seeking (..45%..) but also have the time displayed as well. This involves a little more. Under this scenario you would already be displaying the advancing time as the video is playing. You can do this by setting your position notification method which generates the IsPlaybackPosition. This position is returned in seconds and can be converted to hh:mm:ss. You could then use this value in your slider to advance or rewind in seconds from the point of duration. It can get involved from a display standpoint but the seek offset is no more complicated than a valid percentage of the whole. What I do is put the video in pause and display the control images overriding the video whenever the user attempts to advance or rewind

The real challenge with the video player is that it is event driven with no direct way as far as I know to check/confirm the state. Using the return values of some functions is unreliable since once the video has played something and you stopped it, the last time I checked, (even with the player stopped and cleaned up) some functions continue to return true. I seem to remember that even getplaybackduration continued to return the value of the previous video even if there was none playing. This may have changed or I could have recalled incorrectly. In any event it took some time for me to build a solid player. You should be able to handle all messages and set the state accordingly. You also need to handle the underrun message. Some of the events are not even documented. There is a thread on here that outlines a few. Waiting for messages to arrive and a user that is toying with the remote must also be addressed. Such as clearing the message queue of certain redundant commands until the first one completes. It all depends on how solid you want it to be
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos

Re: Rovideoplayer and roimagecanvas

Hi,

Thanks for the useful information based on which i was able to implement most of the functionality. But i am trying the below use case and i am not able to get a valid approach.

When user press forward or rewind button, a event gets fired which i can listen and increase or decrease the playback position once, but what i want to achieve is it continuously increase or decrease until user presses play button.

Regards,
Prajwal
0 Kudos