Blog

  • Video in roku

    Posted by Prashant Grover | Last Updated: 12-Jan-17

    How to play video in roku.

     

    In roku sdk there is a class called Video Node which is used to provide controllers to play live or VOD video. Video Node class provide rich variety of nodes which is supports many Video functionality such as (trick play, buffering indicators, and many more). You must be thinking about what is buffering indicators stands for – well this indicators are used to indicate buffering before initial playback as well as rebuffering, buffering indicators use an internal instance of a ProgressBar node. For Trick Play, internal trick play node has been provide you just have to enable it. For displaying BIF images, an internal node BIFDisplay node has been provided, for each and every video related functionality a seperate node has been provided by roku.

     

    For playing a particular video we need to set some specific video parameters of that video which we are going to play and we can set them by setting the CONTENT META-DATA attributes for the video in a CONTENT NODE, node and after you are done with this assign the CONTENTNODE node to the content field of the video node.

     

    To Control the video states i.e “Play, stop resume and pause”, that can be control by setting the value of Control field, for eg: setting the node to Pause will pause the current playing video.

     

    > m.videoPlayer.control = “Pause”

     

    The control field includes another state also apart from above mention states i.e “ prebuffer ”, which allows the video to begin buffering without showing the video, the is used to make end user feel that the video is loading faster.

     

    > m.videoPlayer.control = “prebuffer”

     

    If you want to play video then, just change is control state to play, this will play the video.

     

    > m.videoPlayer.control = “play”

     

    Example :

     

    This exmaple will illlustrate you, how you can play a video, so before playing any video in your application, you first need to create a Video Node, you can create a Video node either in Bright Script using the roSGNode, or in Xml markup, in the below example we are going to create video node in Xml Markup.

     

    <Video

    id="videoPlayer"

    width="1280"

    height="720"

    translation="[0,0]"

    />

     

    Each node is assigned a unique id, which is used to identify it – in this example my Video Node id is “ videoPlayer ”, height, width and translation you can set according to your choice.

     

    Then we need to specify the URL of the video stream, streaming format, video title, and any other Content Meta-Data attributes needed for the particular playback in the bright script. Please have a look in the below example :

     

    <script type="text/brightscript" >

    <![CDATA[

     

    sub init()

    initializeVideo()

    end sub

     

    function initializeVideo()

     

    m.videoPlayer = m.top.findNode(“videoPlayer”) ' here pass the video node is which you have created just above in the Xml markup.

     

    content = createObject("RoSGNode", "ContentNode")

    content.url = "Pass any video url"

    content.title = "My First Video"

    content.streamformat = "pass video format i.e (mp4, hds, mkv)"

     

    m.videoPlayer.content = content ' this is where setting the video paramters which are must for any video.

    m.videoPlayer.control = "play" ' this willl start playing the video.

     

    end function

     

    ]]>

    </script>

    THANKS

Tags: roku

View All PostsLeave a Comment
comments powered by Disqus

Mobile Applications

Video Content

Bigdata & NoSQL

SaaS Applications

Miscellaneous

Archives


Alexa Certified Site Stats for www.oodlestechnologies.com