Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #220 from Wikia/XW-4169
Browse files Browse the repository at this point in the history
XW-4169 | autoplay toggle in featured videos
  • Loading branch information
latata authored Nov 7, 2017
2 parents 17c5206 + d826d8a commit 2dc1e57
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 8 deletions.
14 changes: 13 additions & 1 deletion app/components/article-featured-video-jwplayer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import VideoLoader from '../modules/video-loader';
import extend from '../utils/extend';
import config from '../config/environment';

const {
Component,
Expand All @@ -12,6 +13,9 @@ const {
export default Component.extend({
ads: inject.service(),

autoplayCookieName: 'featuredVideoAutoplay',
autoplayCookieExpireDays: 14,

// when navigating from one article to another with video, we need to destroy player and
// reinitialize it as component itself is not destroyed. Could be done with didUpdateAttrs
// hook, however it is fired twice with new attributes.
Expand All @@ -32,6 +36,14 @@ export default Component.extend({
*/
onCreate(player) {
this.player = player;

this.player.on('autoplayToggle', (data) => {
$.cookie(this.get('autoplayCookieName'), data.enabled ? '1' : '0', {
expires: this.get('autoplayCookieExpireDays'),
path: '/',
domain: config.cookieDomain
});
});
},

/**
Expand All @@ -40,7 +52,7 @@ export default Component.extend({
initVideoPlayer() {
const model = this.get('model.embed'),
jsParams = {
autoplay: true,
autoplay: $.cookie(this.get('autoplayCookieName')) !== '0',
adTrackingParams: {
adProduct: this.get('ads.noAds') ? 'featured-video-no-preroll' : 'featured-video-preroll',
slotName: 'FEATURED'
Expand Down
2 changes: 0 additions & 2 deletions app/initializers/ember-hammer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export function initialize() {

window.emberHammerOptions = {
hammerOptions: {
// we are using fastclick as this is advised by ember-hammer lib
ignoreEvents: [],
swipe_velocity: 0.1,
pan_threshold: 1
}
Expand Down
6 changes: 4 additions & 2 deletions app/modules/video-players/jwplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ export default class JWPlayer extends BasePlayer {
setCustomDimension: M.tracker.UniversalAnalytics.setDimension,
comscore: config.environment === 'production'
},
autoplay: {
enabled: this.params.autoplay,
settings: {
showAutoplayToggle: true,
},
autoplay: this.params.autoplay,
mute: this.params.autoplay,
related: {
time: 3,
playlistId: this.params.recommendedVideoPlaylist || 'Y2RWCKuS',
Expand Down
7 changes: 7 additions & 0 deletions app/styles/component/_article-featured-video-jwplayer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.jwplayer {
// resets wikia-style-guide styles
input[type="checkbox"] + label {
margin-left: 0;
margin-right: 0;
}
}
1 change: 1 addition & 0 deletions app/styles/component/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@import 'wikia-user-profile';
@import 'show-error';
@import 'article-featured-video';
@import 'article-featured-video-jwplayer';
@import 'recirculation';
@import 'fandom-app-smart-banner';

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mobile-wiki",
"dependencies": {
"design-system": "wikia/design-system#8.11.0",
"design-system": "wikia/design-system#8.11.1",
"ember-hammer": "1.0.2",
"hammerjs": "2.0.4",
"headroom.js": "0.7.0",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"fastboot": "github:wikia/fastboot#582162a5e2eb39c2d94f857e53ee0efff4544447",
"fastboot-app-server": "1.0.1",
"html5-skin": "github:wikia/html5-skin#84574003c0cf2fa6de499bd6e7423a2a37681e44",
"jwplayer-fandom": "github:wikia/jwplayer-fandom#1.0.8",
"jwplayer-fandom": "github:wikia/jwplayer-fandom#1.0.9",
"method-override": "2.3.10",
"newrelic": "2.2.1",
"on-headers": "1.0.1",
Expand All @@ -61,7 +61,6 @@
"ember-cli-deprecation-workflow": "0.2.3",
"ember-cli-eslint": "4.2.0",
"ember-cli-fastboot": "1.0.5",
"ember-cli-fastclick": "1.4.0",
"ember-cli-head": "0.3.1",
"ember-cli-htmlbars": "2.0.3",
"ember-cli-htmlbars-inline-precompile": "1.0.2",
Expand Down

0 comments on commit 2dc1e57

Please sign in to comment.