Skip to content

Instantly share code, notes, and snippets.

View zoharbabin's full-sized avatar

Zohar Babin zoharbabin

View GitHub Profile
//reset these with every player load/playback session
var PLAY_REACHED_25_PERCENT = false;
var PLAY_REACHED_50_PERCENT = false;
var PLAY_REACHED_75_PERCENT = false;
var PLAY_REACHED_100_PERCENT = false;
kalturaPlayer.addEventListener(kalturaPlayer.Event.Core.TIME_UPDATE, function (event) {
var progpercent = kalturaPlayer.currentTime / kalturaPlayer.duration;
if (!PLAY_REACHED_25_PERCENT && progpercent >= 0.25) {
PLAY_REACHED_25_PERCENT = true;
@zoharbabin
zoharbabin / kaltura-v7-requireJS-embed.php
Last active July 5, 2019 17:16
Sample code - how to embed the Kaltura Player v7 on a site that uses requireJS
<?php
//This goes on your backend - never include API secret keys in front end code
$expire=60*60*24; //one day
$uniqueUserId = 'someUniqueUserId'; //Make sure this is set to your real user IDs so that Analytics and Entitlements will really be tracked according to your business needs
$partnerId = REPLACE_ME; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$apiAdminSecret = 'REPLACE_ME'; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$uiconfId = REPLACE_ME; //https://kmc.kaltura.com/index.php/kmcng/studio/v3
$entryId = 'REPLACE_ME'; //https://kmc.kaltura.com/index.php/kmcng/content/entries/list
$appName = 'MyAppName'; //used to designate your application name, this can be used in the Analytics later to differentiate usage across different apps (such as website vs. mobile iOS vs. mobile Android vs. partner site)
$appDomain = 'my.appdomain.com'; // the domain to track this playback session to
@zoharbabin
zoharbabin / recorder-embed.php
Created July 8, 2019 12:21
How to embed the Kaltura recorder widget
<?php
//This PHP part of the code goes on your backend - never include API secret keys in front end code
$partnerId = REPLACEME; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$apiAdminSecret = 'REPLACEME'; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings (Admin Secret)
$expire=60*60*24; //one day
$uniqueUserId = 'someUniqueUserId'; //Make sure this is set to your real user IDs so that Analytics and Entitlements will really be tracked according to your business needs
$uiconfId = REPLACEME; //https://kmc.kaltura.com/index.php/kmcng/studio/v3
$appName = 'expressrecorder'; //used to designate your application name, this can be used in the Analytics later to differentiate usage across different apps (such as website vs. mobile iOS vs. mobile Android vs. partner site)
$appDomain = 'my.appdomain.com'; // the domain to track this playback session to
//generate the Kaltura Session for secure and tracked playback session
@zoharbabin
zoharbabin / lazyloadkaltura.html
Created July 11, 2019 14:55
Lazy load many Kaltura videos sample reference
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
box-sizing: border-box;
}
from KalturaClient import *
config = KalturaConfiguration(<PARTNER ID>)
client = KalturaClient(config)
ks = client.session.start(
<ADMIN SECRET>,
<YOUR EMAIL ADDRESS>,
KalturaSessionType.ADMIN,
<PARTNER ID>
)
client.setKs(ks)
entry = KalturaMediaEntry()
entry.mediaType = KalturaMediaType.VIDEO
entry.name = "Sample Video"
entry.description = "yet another sample video in my arsenal"
mediaEntry = client.media.add(entry)
uploadToken = KalturaUploadToken()
result = client.uploadToken.add(uploadToken)
tokenId = result.id
uploadToken = KalturaUploadToken()
result = client.uploadToken.add(uploadToken)
tokenId = result.id
fileData = open('IMG_9227.m4v', 'r')
result = client.uploadToken.upload(tokenId, fileData)