Skip to content

Instantly share code, notes, and snippets.

View ovlb's full-sized avatar
🦉
Owlish

Oscar ovlb

🦉
Owlish
View GitHub Profile
// header.php
/**
* setcookie() needs to be called before the opening <html> tag
*/
<?php
// Fallback if client side script fails and there is an opt out request
$opt_out_request = $_GET['fb-pixel-status'];
$wants_to_opt_out = isset($opt_out_request) && $opt_out_request === 'opt-out';
@ovlb
ovlb / ks-video-show-image-ended.js
Last active February 7, 2019 00:23
KS Video – Show image if video ends
this.$vidContainer.addEventListener('ended', () => {
VideoPlayerController.showImage(this.$imgContainer)
// Hand back control to this class
this.userControls = false
})
@ovlb
ovlb / ks-video-adding-controls.js
Created February 7, 2019 00:21
KS Video – adding video controls
this.$vidContainer.setAttribute('controls', 'true')
@ovlb
ovlb / ks-video-format-detection.js
Last active February 7, 2019 00:17
KS – Video format detection
static hlsSupported() {
const $vid = document.createElement('video')
return (
$vid.canPlayType('application/x-mpegURL codecs="avc1.42E01E"') ||
$vid.canPlayType('application/vnd.apple.mpegurl')
)
}
@ovlb
ovlb / ks-video-hiding-image.js
Created February 5, 2019 23:20
KS Video – Hide preview image
static showImage($img) {
$img.classList.remove('video-container__image--hidden')
}
@ovlb
ovlb / ks-video-play.js
Created February 5, 2019 23:13
KS Video – Play video
playVideo() {
console.log('HLS – Playing video')
VideoPlayerController.hideImage(this.$imgContainer)
this.$vidContainer.play().then(() => {
console.log('HLS - Video played')
})
}
@ovlb
ovlb / ks-video-library-parse.js
Created February 5, 2019 23:09
KS Video – Parse HLS manifest with library
parseHlsManifest() {
console.log('HLS – Parsing video manifest')
const { Hls } = window
const hls = new Hls()
const { src } = this.$vidContainer
hls.loadSource(src)
hls.attachMedia(this.$vidContainer)
hls.on(Hls.Events.MANIFEST_PARSED, () => {
this.parsed = true
@ovlb
ovlb / vue.config.alias.js
Created January 25, 2019 17:51
Vue Open Source: Webpack Resolve Alias
const path = require('path')
module.exports = {
// outputDir: path.resolve(__dirname, 'dist-demo'),
chainWebpack: config => {
// config
// .entry('app')
// .clear()
// .add('./demo/main.js')
config.resolve.alias
@ovlb
ovlb / vue.config.entry.js
Created January 25, 2019 17:48
Vue Open Source: Webpack Config Entry
const path = require('path')
module.exports = {
// outputDir: path.resolve(__dirname, 'dist-demo'),
chainWebpack: config => {
config
.entry('app')
.clear()
.add('./demo/main.js')
// config.resolve.alias
@ovlb
ovlb / vue.config.output.js
Last active January 25, 2019 17:47
Vue Open Source: vue.config.js – Output
const path = require('path')
module.exports = {
outputDir: path.resolve(__dirname, 'dist-demo'),
// chainWebpack: config => {
// config
// .entry('app')
// .clear()
// .add('./demo/main.js')
// config.resolve.alias