Change the mode of the player

In this example, we change the mode of the Nimbb Player. Using Javascript, we change to playback mode once the recording is completed. We start playing the video automatically and add a link to return to recording mode.

This example requires you to specify your developer key (see tutorial).

Example

Record a video and click Save to change the mode of the player.



Recording mode

HTML code

<script language="JavaScript" type="text/javascript">
<!--

// Global variable to hold player's reference.
var _Nimbb;

// Event: Nimbb Player has been initialized and is ready.
function Nimbb_initCompleted(idPlayer)
{
  // Get a reference to the player since it was successfully created.
  _Nimbb = document[idPlayer];
}

// Event: the video was saved.
function Nimbb_videoSaved(idPlayer)
{
  var guid;

  // Get the GUID of the saved video.
  guid = _Nimbb.getGuid();

  // Set the player in view mode.
  _Nimbb.setMode('view');
	
  // Assign the GUID.
  _Nimbb.setGuid(guid);
	
  // Start playback now.
  _Nimbb.playVideo();
}

// Return to recording mode.
function modeRecord()
{
  // Make sure the player is not in recording mode.
  if( _Nimbb.getMode() == "record" )
  {
    alert("The player is already in recording mode.");
    return;
  }
	
  // Set the player in recording mode.
  _Nimbb.setMode('record');
}

// -->
</script>
Record a video and click Save to change the mode of the player.
<br><br>

<object id="nimbb" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240" codebase= "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="http://player.nimbb.com/nimbb.swf?mode=record&key=XXXXXXXXXX&lang=en" />
<param name="allowScriptAccess" value="always" />
<embed name="nimbb" src="http://player.nimbb.com/nimbb.swf?mode=record&key=XXXXXXXXXX&lang=en" width="320" height="240" allowScriptAccess="always" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash">
</embed>
</object>

<br><br>
<a href="javascript:modeRecord();">Recording mode</a>

In the code, we use the event Nimbb_videoSaved() to get the video GUID and then set the player in view mode with method setMode().

Also note the function modeRecord(), where we set the player back in recording mode.

View more tutorials.

SIGN UP NOW 7-day free trial

Check out our Developer guide to get started with Nimbb.