Commit 602e0435 by Kurt Berglund

Add in a slide change event. Update event data based on eventing review

parent fc09b3a9
...@@ -5,23 +5,47 @@ function OfficeMixBlock(runtime, element) { ...@@ -5,23 +5,47 @@ function OfficeMixBlock(runtime, element) {
var mixUrl = iframe.attr('src'); var mixUrl = iframe.attr('src');
var eventUrl = runtime.handlerUrl(element, 'publish_event'); var eventUrl = runtime.handlerUrl(element, 'publish_event');
/**
* The API returns slides in a 0-based format. Add one to convert into a more human readable format
*/
function convertSlideIndex(slide) {
return slide + 1;
}
/**
* Retrieves the current time and slide from the playing Office Mix
*/
function getCurrentTimeAndSlide (callback) {
player.getCurrentTime(function (currentTime) {
player.send({ method: 'getCurrentPage' }, function (currentSlide) {
callback(currentTime, convertSlideIndex(currentSlide));
});
});
}
player.on('ready', function () { player.on('ready', function () {
player.getDuration(function (duration) { player.getDuration(function (duration) {
var data = { player.send({ method: 'getPageCount' }, function (totalSlides) {
'event_type': 'microsoft.office.mix.loaded', var data = {
url: mixUrl, 'event_type': 'microsoft.office.mix.loaded',
duration: duration url: mixUrl,
}; duration: duration,
totalSlides: totalSlides
};
$.post(eventUrl, JSON.stringify(data)); $.post(eventUrl, JSON.stringify(data));
});
}); });
player.on('play', function () { player.on('play', function () {
player.getCurrentTime(function (value) { getCurrentTimeAndSlide(function (currentTime, currentSlide) {
var data = { var data = {
'event_type': 'microsoft.office.mix.played', 'event_type': 'microsoft.office.mix.played',
url: mixUrl, url: mixUrl,
time: value currentTime: currentTime,
currentSlide: currentSlide
}; };
$.post(eventUrl, JSON.stringify(data)); $.post(eventUrl, JSON.stringify(data));
...@@ -29,11 +53,12 @@ function OfficeMixBlock(runtime, element) { ...@@ -29,11 +53,12 @@ function OfficeMixBlock(runtime, element) {
}); });
player.on('pause', function () { player.on('pause', function () {
player.getCurrentTime(function (value) { getCurrentTimeAndSlide(function (currentTime, currentSlide) {
var data = { var data = {
'event_type': 'microsoft.office.mix.paused', 'event_type': 'microsoft.office.mix.paused',
url: mixUrl, url: mixUrl,
time: value currentTime: currentTime,
currentSlide: currentSlide
}; };
$.post(eventUrl, JSON.stringify(data)); $.post(eventUrl, JSON.stringify(data));
...@@ -48,5 +73,15 @@ function OfficeMixBlock(runtime, element) { ...@@ -48,5 +73,15 @@ function OfficeMixBlock(runtime, element) {
$.post(eventUrl, JSON.stringify(data)); $.post(eventUrl, JSON.stringify(data));
}); });
player.on('pageupdate', function (pageUpdateEvent) {
var data = {
'event_type': 'microsoft.office.mix.slide_changed',
url: mixUrl,
slide: convertSlideIndex(pageUpdateEvent.page)
};
$.post(eventUrl, JSON.stringify(data));
});
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment