Rumble Player API


Rumble Player API

The following is functionality that can be called on the API class provided from the optional configuration parameter api.

Ex:

Rumble("play", {video: "vabcd", div: "rumblePlayer", api: function(api) {
  /* API calls can go here, or you can pass the API to your own functions */
}});

Examples


Player Examples

  • The following is an example of an iframe embed with the publisher code and video id highlighted for use with the new javascript player:

    <iframe src="https://rumble.com/embed/uabcd.vabcd/?rel=5" frameborder="0" allowfullscreen></iframe>
  • To embed using the javascript player you must create a container to place the player into like a div:

    <div id="rumblePlayer"></div>
  • You must also load the javascript library required for the player while replacing the [pub-code] with the appropriate publisher code that always starts with “u”. This can be grabbed from any embed code and only contains numbers and letters.

    <script>
    !function(r,u,m,b,l,e) {
    r._Rumble=b,r[b]||(r[b]=function(){
    (r[b]._=r[b]._||[]).push(arguments);
    if(r[b]._.length==1){
    l=u.createElement(m),e=u.getElementsByTagName(m)[0],
    l.async=1,l.src="https://rumble.com/embedJS/[pub-code]"+
    (arguments[1].video?'.'+arguments[1].video:'')+"/?url="+
    encodeURIComponent(location.href)+"&args="+
    encodeURIComponent(JSON.stringify([].slice.apply(arguments))),
    e.parentNode.insertBefore(l,e)
    }})}(window,document,"script","Rumble");
    </script>
  • To initialize the player you call the function

    Rumble("play", [config]);
  • The following are mandatory config parameters that every player must have:

Parameter Example Value Description
video "vabcd" Video ID of the video you want to be loaded
div "rumblePlayer" The ID of the container on the page you want the Rumble player loaded in
  • Example with the above options:
Rumble("play", {video: "vabcd", div: "rumblePlayer"});
  • Optional config parameters:
Parameter Example Value Description
rel 5 Related content to use at the end of the video, this is also used for the next video timer at the end of the video.
0 – disable related
1 – enable related
5 – enable related, use only videos from the same channel or user as the current video
ia 1 Use optimizations for instant articles, this will fix possible sizing issues
0 – disabled
1 – enabled
playlist ["v1235", "v1236"] The video IDs listed here will replace what content is used in the auto timer at the end of the video
api function(api){...} When specified the player will call the function provided (when the player loads) with a class you can interface with to control the player instance. To see more documentation on the calls available look to the next section of this document.
refadd player_placement=top&ctp=1 Optional, the string will be used for reporting purposes, it will be appended to the end of the URL. Please note, you do not provide a '?', the player will automatically parse it and add it if needed.
opts ["enablesnd","nopreload"] List of options to enable in the player:

"enablesnd" - show Enable sound overlay even over the video
"nopreload" - do not prepare the video for playing
"cssleak" - use only when a page's CSS has altered the appearance of the player, likely there is an improper approach utilized on your page if this option is needed
"force_ga_load" - the player will wait/try to use GA on your page, this options skips this check and loads GA on it's own without waiting
ui {logo:{"display-min":600}} If you have a custom player, you will be able to control when specific UI elements render.

Here is a list of available controls:
"fullscreen" - icon for making the player fullscreen
"logo" - logo of the player
"play" - play/pause button
"scrubber" - video scrubber/seek bar
"settings" - gear icon, used for changing resolutions
"sound" - mute/sound levels
"time" - current time/duration of video

Here are the available settings you can specify for them:
"display-min" - width of player needed to display this control (ie: 600 would make the element disappear when the player is smaller than 600px)
"display-max" - maximum width of player for displaying element
"display-pmode" - only display element when the player is "ctp" or "autoplay"
"hidden" - setting this to any value will make the element always hidden
  • To load the player in an instant article a non-async approach should be used, and the video IDs are duplicated like so:
<figure class="op-interactive"><iframe>
<div id="rumblePlayer"></div>
<script src="https://rumble.com/embedJS/uabcd.vabcd/"></script>
<script >Rumble("play", {video: "vabcd", div: "rumblePlayer", rel: 5, ia: 1})</script>
</iframe></figure>

Methods


Rumble Player API

The following is functionality that can be called on the API class provided from the optional configuration parameter api.

Ex:

Rumble("play", {video: "vabcd", div: "rumblePlayer", api: function(api) {
  /* API calls can go here, or you can pass the API to your own functions */
}});

Player Methods

API.loadVideo(video, [play])

  • Changed the video currently in the player
  • Parameters:
    • video – video ID to be loaded
    • play – [optional] whether to auto play the video, only able to do this on your own videos and if a user has already clicked on the player before

API.getCurrentVideo()

  • Returns an object with the following:
    • id - the video ID
    • link - Link to the video on rumble.com
    • own - Whether the video is your own video
    • plays - Number of times this video has been played
    • thumb - Thumbnail of the video
    • title - Title of the video

API.play([force])

  • Plays the video loaded. This function will only be successful if one of the following conditions are met:
    1. The video has already played and has since been paused or ended
    2. You own the video and the player has previously been clicked on.
    3. You own the video and you call the function with true for the force optional parameter.
  • Please note that if the video has not be interacted with previously and you try to force the video the browser may block it unless you mute the video first.

API.pause()

  • Pauses the current video if it is playing

API.getPaused()

  • Returns true or false depending if the video is playing or not.

API.mute()

  • Mute the volume on the player

API.unmute()

  • Un-mute the volume on the player

API.getMuted()

  • Returns true or false whether the player is muted

API.setVolume(vol)

  • Sets the volume on the player. The value passed should be between 0 and 1 inclusively, with 1 being full volume. If the player is muted this will unmute it automatically.

API.getVolume()

  • Returns the volume of the player. If the player is muted the value for this will be 0

API.getDuration()

  • Get the length of the currently loaded video in seconds

API.setCurrentTime(time)

  • Seek the current video to the time in number of seconds, if the video is playing it will skip to the time and continue playing.

API.getCurrentTime()

  • Get the current time of where the video is playing in seconds.

API.off(eventName, [func])

  • Removes event listeners on the player. All functions are removed if the optional “func” parameter is not provided, otherwise the function provided in “func” is only removed”. A list of all events available is listed in API.on

API.on(eventName, func)

  • Add an event listener to the player. An object is passed to your function if there is need for more than one value for the event. Here is a list of available events.
Event Name Event passed to function Description
loadVideo When a video is loaded from the server and is ready
resize When the player has resized and the UI updated due to it
preplay Right before the video is played, best time to set the ads is here or on “preAd”
preAd Type of ad Fired before attempting to run an ad
play After the play call is made to the video, this is where ads are fired if there is a reason to.
pause Fired when the video player is paused
mute The new volume value Fired when the video is muted or unmuted
volumeChange The new volume value Fired when the volume has been changed
videoEnd The time in seconds of the video When the video has come to an end, best time to show an overlay
ui True/false wheter the player’s UI is shown Fired when the player’s UI changes state
adError Object:
{code: errCode, msg: message}
Fired if an error occurs in any of the ads
adImpression Object:
{ad: curAd, adType: type, linear: isLinear}
Fired when an ad impression is called
adClick Same as adImpression Fired when an ad has been clicked
adComplete Fired when the ad finishes/completes
adCompanions Array of companion ads Fired when an ad has companion banners
adRequest Object:
{url: ad_url, callback: callback_function}
This event only fires on your own ad tags. If you return a value from this event it will modify the current request.

Return:
false - will skip this ad
true - will make the player wait till the callback_function is called where you can pass a value as a parameter to modify the request
string - passing back a string will change the ad request to the string, this allows you to implement prebid or can be used as another way to add additional information/macros to the request
undefined - continues with the ad request untouched
  • Rumble Player API
  • Player Examples
  • Rumble Player API
  • Player Methods
    • loadVideo
    • getCurrentVideo
    • play
    • pause
    • getPaused
    • mute
    • unmute
    • getMuted
    • setVolume
    • getVolume
    • getDuration
    • setCurrentTime
    • getCurrentTime
    • off
    • on
...