Allows interaction between the customer and the video Player via the Digiteka iframe
<iframe id="player" src="urlplayer"></iframe>
<script>
// Listener for postMessage
window.addEventListener('message', function (postMessage) {
// postMessage.source contains a reference to the window object of the iframe
// postMessage.data contains the content of the message
// see the Events section for the full list of available events
}, false);
</script>
document.getElementById("idIframe").contentWindow(message, '*');
The full list of available messages is as below :
- play
- To start the video playback (starts the preroll ad if applicable)
- Play_loadVideo
- To start the playback of another video when a video is already playing
- pause
- To pause the video playback
- pause_
- To pause the video or preroll playback
- mute
- To switch the sound status (both video and ad)
- mute=1
- To mute the player (both video and ad)
- mute=0
- To switch the sound back on (both video and ad)
- getCurrentTime
- To get the current playback position. The event=getCurrentTime&time=\f postMessage will be sent as a response (where \f will be replaced with the playback position in the video)
- getDuration
- To get the video duration. The event=getDuration&duration=\f postMessage will be sent as a response (where \f will be replaced with the total duration of the video)
- setCurrentTime=\f
- To change the playback position to \f. For instance : setCurrentTime=15
You can detect some event of the player by listening to the followinf postMessages.
Instructions to add a listener to our postMessages :
- window.addEventListener("message", function (message) { /*yourimplementation*/ }, false);
- Available values for message.data :
- playerevent_onSetupError_{"code":\d,"message":"\s"}
- Sent when an error occurs in the player. \d will be replaced with the error code and \s with the corresponding message
- event=ready
- Sent when the player is ready
- event=adready
- Sent when the ad is fully loaded and ready to play
- event=ended
- Sent when the video is ended
- event=AdPlay
- Sent when the ad playback is resumed (but not on impression)
- event=AdPause
- Sent when the ad is being paused
- event=AdImpression
- Sent when the ad starts playing
- event=AdError
- Sent when the ad could not be loaded
- event=AdComplete
- Sent when the ad has been fully played (Not sent if the ad has been skipped)
- event=paused
- Sent when the video is being paused
- event=played
- Sent when the video starts playing (after an ad) or when the video is being resumed (after a pause)
- event=resize
- Sent when the player is being resized
- event=timeupdate&time=\1f&duration=\2f
- Sent when the playback position changes. \1f will be replaced with the current position, and \2f with the video's total duration. For instance : event=timeupdate&time=336.181745&duration=341.123333
The use case code below is calling the “play” method
<iframe id="player"
src="//www.ultimedia.com/deliver/generic/iframe/mdtk/01713870/src/5slxzm/zo
ne/2 "></iframe>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(message) {
};
var player = document.getElementById('player');
player.contentWindow.postMessage('play', '*');
</script>