Skip to content

Instantly share code, notes, and snippets.

Avatar

Amitai Blickstein AmitaiB

View GitHub Profile
@AmitaiB
AmitaiB / JWAdCompanion_MockImplementation.swift
Last active Jul 6, 2022
Quick and dirty JWAdCompanion implementation
View JWAdCompanion_MockImplementation.swift
// In a JWPlayerViewController, with player configured, etc.
// For example, our BPA: https://github.com/jwplayer/jwplayer-ios-bestPracticeApps
// Override the implementation of this JWAdDelegate method,
// which reports when any ad event is emitted by the player.
override func jwplayer(_ player: AnyObject, adEvent event: JWAdEvent) {
super.jwplayer(player, adEvent: event) // When overriding (only), must call the `super` method.
if let companions = event[.companions] as? [JWAdCompanion] {
handleCompanion(companions.first)
}
@AmitaiB
AmitaiB / JWPlayer+Mute.swift
Last active Jun 1, 2022
Extends JWPlayer to have basic mute API
View JWPlayer+Mute.swift
//
// JWPlayer+Mute.swift
//
// Created by Amitai Blickstein on 6/1/22.
//
import Foundation
import JWPlayerKit
fileprivate let kVolumeKey = "kVolumeKey"
@AmitaiB
AmitaiB / AudioInterruptionMonitor.swift
Created Aug 13, 2021
Modified Audio Interruption Monitor with delegate pattern
View AudioInterruptionMonitor.swift
//
// AudioInterruptionMonitor.swift
// JWPlayerDemo
//
// Created by Amitai Blickstein
// Copyright © 2019. All rights reserved.
//
// Credit: Code modified from Mohamed Afifi ->
// https://github.com/quran/quran-ios/blob/master/QueuePlayer/AudioInterruptionMonitor.swift
View WingedFruit.vtt
WEBVTT
NOTE This file was exported by MacCaption version 7.0.12 to comply with the WebVTT specification dated March 27, 2017.
01:00:09.306 --> 01:00:12.876 align:middle line:-1 position:31% size:43%
- Hello again, it's Winged
Nation presented by Sage Fruit.
01:00:12.876 --> 01:00:14.611 align:middle line:-1 position:50% size:33%
Talking sprint car racing,
@AmitaiB
AmitaiB / JWDelayedCastingCall.swift
Last active Dec 22, 2020
One possible way to call `cast` in the onConnected delegate method (https://developer.jwplayer.com/)
View JWDelayedCastingCall.swift
func onConnected(to device: JWCastingDevice) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.castController.cast()
}
}
View PrettyPrinter.swift
class PrettyPrinter {
static func print(json tryJSON: Any) -> String {
var result = "\(tryJSON)"
do {
guard JSONSerialization.isValidJSONObject(tryJSON) else { return result }
let data = try JSONSerialization.data(withJSONObject: tryJSON, options: .prettyPrinted)
guard let string = String(data: data, encoding: .utf8) else { return result }
result = string
}
catch {
@AmitaiB
AmitaiB / jwSampleVMAP.xml
Created Feb 4, 2020
Sample VMAP from JW Player website
View jwSampleVMAP.xml
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0">
<vmap:AdBreak timeOffset="start" breakType="linear" breakId="preroll">
<vmap:AdSource id="preroll-ad" allowMultipleAds="false" followRedirects="true">
<AdTagURI templateType="vast3">
<![CDATA[preroll.xml]]>
</AdTagURI>
</vmap:AdSource>
</vmap:AdBreak>
<vmap:AdBreak timeOffset="50%" breakType="linear" breakId="midroll">
<vmap:AdSource id="overlay-1-ad" allowMultipleAds="false" followRedirects="true">
@AmitaiB
AmitaiB / jwpIssueTemplate.md
Last active Jan 6, 2020
JWP Issue Report Template
View jwpIssueTemplate.md

Issue Summary:

Given Some Conditions,
When A Certain Action-is-Taken or Specific-Stimulus-Occurs,
It Results In This Unexpected Situation/Response

JWP SDK Ver #:

iOS SDK 3.9.0

OS Version:

iOS 13.3

View NSObject+LogProperties.h
//
// NSObject+LogProperties.h
// JWPlayer-SDK-iOS-Demo
//
// Created by Amitai Blickstein on 6/15/19.
// Copyright © 2019 JWPlayer. All rights reserved.
//
#import <Foundation/Foundation.h>
@AmitaiB
AmitaiB / AudioInterruptionMonitor.swift
Created Jun 17, 2019
Elegant implementation of iOS Audio Interruption Notification subscription Monitor in Swift, from Quran.com
View AudioInterruptionMonitor.swift
//
// AudioInterruptionMonitor.swift
// QueuePlayer
//
// Created by Afifi, Mohamed on 4/29/19.
// Copyright © 2019 Quran.com. All rights reserved.
//
// originally DL'ed from https://github.com/quran/quran-ios/blob/master/QueuePlayer/AudioInterruptionMonitor.swift
import AVFoundation