recsys take 99

This commit is contained in:
Thomas Zarebczan 2022-02-04 18:38:42 -05:00
parent ffcf09efd0
commit fd1ee4f43c
No known key found for this signature in database
GPG key ID: D505010BDB4364BC
2 changed files with 14 additions and 2 deletions

View file

@ -43,6 +43,7 @@ const recsys = {
* - pageLoadedAt * - pageLoadedAt
* - isEmbed * - isEmbed
* - pageExitedAt * - pageExitedAt
* - autoplay
* - recsysId // optional * - recsysId // optional
*/ */
@ -152,6 +153,16 @@ const recsys = {
* @param event * @param event
*/ */
onRecsysPlayerEvent: function (claimId, event, isEmbedded) { onRecsysPlayerEvent: function (claimId, event, isEmbedded) {
const state = window.store.getState();
const autoPlayNext = state && selectClientSetting(state, SETTINGS.AUTOPLAY_NEXT);
// Check if played through (4 = onEnded) and handle multiple events at end
if (recsys.entries[claimId] && !recsys.entries[claimId]['autoplay'] === true) {
if (autoPlayNext && event.event === 4) {
recsys.entries[claimId]['autoplay'] = true;
} else {
recsys.entries[claimId]['autoplay'] = false;
}
}
if (!recsys.entries[claimId]) { if (!recsys.entries[claimId]) {
recsys.createRecsysEntry(claimId); recsys.createRecsysEntry(claimId);
// do something to show it's floating or autoplay // do something to show it's floating or autoplay
@ -235,7 +246,7 @@ const recsys = {
const shouldSkip = recsys.entries[claimId].parentUuid && !recsys.entries[claimId].recClaimIds; const shouldSkip = recsys.entries[claimId].parentUuid && !recsys.entries[claimId].recClaimIds;
if (!shouldSkip && ((claimId !== playingClaimId && floatingPlayer) || !floatingPlayer)) { if (!shouldSkip && ((claimId !== playingClaimId && floatingPlayer) || !floatingPlayer)) {
recsys.entries[claimId]['pageExitedAt'] = Date.now(); recsys.entries[claimId]['pageExitedAt'] = Date.now();
recsys.sendRecsysEntry(claimId); // recsys.sendRecsysEntry(claimId); breaks pop out = off, not helping with browser close.
} }
recsys.log('OnNavigate', claimId); recsys.log('OnNavigate', claimId);
}); });

View file

@ -11,6 +11,7 @@ const PlayerEvent = {
stop: 1, stop: 1,
scrub: 2, scrub: 2,
speed: 3, speed: 3,
ended: 4,
}, },
}; };
@ -86,7 +87,7 @@ class RecsysPlugin extends Component {
} }
onEnded(event) { onEnded(event) {
const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.stop, this.player.currentTime()); const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.ended, this.player.currentTime());
this.log('onEnded', recsysEvent); this.log('onEnded', recsysEvent);
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent); RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent);
} }