Skill Level: 
Appropriate for all

UNL MediaHub allows you to place media in other websites via embed code. To get the embed code, simply click the 'Embed' button on the media's page in MediaHub.

Options

The iframe embed code allows for the following options via url parameters. Note that some of these options are not available with old versions (non-iframe) of the embed code:

&autoplay=0
This can be changed to &autoplay=1 to auto play the media on page load. Please note that auto-playing media is discouraged as it is often seen as distracting and annoying, however it may be appropriate to auto play media in certain circumstances.
&captions=en
The captions parameter can be used to automatically display captions when the video loads. Set the value of the captions parameter to the BCP 47 language code that you want to be displayed. Do not include the captions parameter if you do not want captions to display automatically.

An embed code with all of the options above defined might look like this:

<div class="wdn-responsive-embed wdn-aspect16x9">
    <iframe src="http://mediahub-test.unl.edu/media/17?format=iframe&autoplay=0&captions=en" title="test 2015-10-08 32" allowfullscreen></iframe>
</div>

Google Analytics for iframes

You may want to track video events on your pages to help determine what content is being interacted with. Fortunately, the 2016-11-08 release of the framework will support this. The tracking is turned off by default (to reduce the number of events sent to GA). You can turn it on by simply including the following JavaScript on your pages.

<script>
  require(['analytics'], function(analytics) {
    analytics.recordMediaHubEvents();
  });
</script>

The event actions that are sent to GA include

play
The play button was pressed
pause
The video was paused
ended
The end of the video was reached

The events are sent to GA with the 'media' event category, the title of the video as the event label, and the event actions are listed above.

Old Embed Code

Old embed code including all script and div based embed code is deprecated. It is recommended to use the new iframe embed code. Old embed code will be unsupported as of 2017-06-15 (1 year after the release of the iframe embed code).

Contributed By: 
IIM