pageflow.pageType.register('video', _.extend({ enhance: function(pageElement, configuration) { pageElement.find('.contentText').before(pageElement.find('.page_header')); this._initVideoPlayer(pageElement, configuration); }, preload: function(pageElement, configuration) { return pageflow.preload.backgroundImage(pageElement.find('.background_image')); }, prepare: function(pageElement, configuration) { this.videoPlayer.ensureCreated(); }, unprepare: function(pageElement, configuration) { this.videoPlayer.scheduleDispose(); }, activating: function(pageElement, configuration) { var videoPlayer = this.videoPlayer; // for SkipLinks $('#firstContent').attr("id",""); var firstContentElement = pageElement.find('*[tabindex="4"], a'); $(firstContentElement[0]).attr('id','firstContent'); // this.videoPlayer.ensureCreated(); if (pageflow.browser.has('mobile platform')) { this.videoPlayer.showPosterImage(); } $('body').on('keyup', function(e) { if(e.keyCode == 32){ if(videoPlayer.paused()) { videoPlayer.play(); } else { videoPlayer.pause(); } } }); }, activated: function(pageElement, configuration) { this.pageElement = pageElement; var videoPlayer = this.videoPlayer; var that = this; if (pageflow.browser.has('mobile platform')) { videoPlayer.src(videoPlayer.srcFromOptions()); // needed for iOS } else { videoPlayer.prebuffer().done(function() { videoPlayer.hidePosterImage(); if (configuration.autoplay !== false) { that.fadeInTimeout = setTimeout(function() { videoPlayer.playAndFadeIn(1000); }, 1000); } }); } }, deactivating: function(pageElement, configuration) { clearTimeout(this.fadeInTimeout); this.fadeSound(this.videoPlayer, 0, 400); this.stopListening(); $('body').off('keyup'); $('.entry .scroll_indicator').removeClass('faded'); clearTimeout(this.scrollIndicatorTimeout); }, deactivated: function(pageElement, configuration) { if (pageflow.browser.has('mobile platform')) { this.videoPlayer.showPosterImage(); } this.videoPlayer.pause(); this.videoPlayer.scheduleDispose(); }, update: function(pageElement, configuration) { pageElement.find('h2 .tagline').text(configuration.get('tagline') || ''); pageElement.find('h2 .title').text(configuration.get('title') || ''); pageElement.find('h2 .subtitle').text(configuration.get('subtitle') || ''); pageElement.find('p').html(configuration.get('text') || ''); this.updateInfoBox(pageElement, configuration); this.updateCommonPageCssClasses(pageElement, configuration); pageElement.find('.shadow').css({opacity: configuration.get('gradient_opacity') / 100}); this.updateVideoPoster(pageElement, configuration.getVideoPosterUrl()); }, embeddedEditorViews: function() { return { '.videoWrapper': { view: pageflow.LazyVideoEmbeddedView, options: { propertyName: 'video_file_id' } } }; }, _initVideoPlayer: function(pageElement, configuration) { var that = this; var videoPlayer = new pageflow.VideoPlayer.Lazy(pageElement.find('[data-template=video]'), { bufferUnderrunWaiting: true, controls: true, customControlsOnMobile: true, volumeFading: true, hooks: pageflow.atmo.createMediaPlayerHooks(configuration), mediaEvents: true, context: { page: pageElement.page('instance') }, width: '100%', height: '100%' }); this.videoPlayer = videoPlayer; pageElement.find('.videoWrapper').data('videoPlayer', videoPlayer); videoPlayer.ready(function() { videoPlayer.showPosterImage(); var addInfoBox = pageElement.find('.add_info_box'), controls = pageElement.find('.controls'), controlBar = pageElement.find('.vjs-control-bar'), playButton = pageElement.find('.vjs-play-control'), loadingSpinner = pageElement.find('.vjs-loading-spinner'), poster = pageElement.find('.vjs-poster'), video = pageElement.find('video'); controlBar.appendTo(controls); var additionalControlsHtml = '