Skip to content

Instantly share code, notes, and snippets.

View michael-riha's full-sized avatar
🎯
Focusing

Michael Riha michael-riha

🎯
Focusing
View GitHub Profile
const analyticsConfig = {
key: '<ANALYTICS-KEY>',
videoId: 'video-empty',
userId: 'xxx_01',
cdnProvider: 'some_cdn',
customData1: 'sport',
title: 'video title set without a source, yet',
debug: true
};
@michael-riha
michael-riha / change-source-videoJS-bmAnalytics.js
Created August 8, 2019 08:41
This is an Snippet on how to change meta-data for videoJS-Adapter with Bitmovin Analytics
document.getElementById('change-source').onclick = function () {
analytics.sourceChange({
title: 'someVideoTitle',
videoId: 'video-1234'
});
player.src({
src: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
type: 'application/x-mpegURL'
});
};
'''
chunked_server_test.py
Copyright August 3, 2012
Released into the public domain
This implements a chunked server using Python threads and the built-in
BaseHTTPServer module. Enable gzip compression at your own peril - web
browsers seem to have issues, though wget, curl, Python's urllib2, my own
async_http library, and other command-line tools have no problems.
// https://github.com/bitmovin/bitmovin-player-android-samples/blob/master/BasicAds/src/main/java/com/bitmovin/player/samples/ads/basic/MainActivity.java
...
import com.bitmovin.player.config.advertising.AdItem;
import com.bitmovin.player.config.advertising.AdSource;
import com.bitmovin.player.config.advertising.AdSourceType;
import com.bitmovin.player.config.advertising.AdvertisingConfiguration;
...
@michael-riha
michael-riha / AndroidTV-ActivityAnalyticsSnippet_2.java
Created January 4, 2019 09:19
Bitmovin Android Analytics Collector setup Part2 - (Part1) github.com/michael-riha/85c5d9629dfc38be9d4c5ad9aaf02a4f
//get this key directly from the AndroidManifest.xml
String playerKey= this.gePlayerLicenseKey();
//Step 1: Create your analytics config object
BitmovinAnalyticsConfig bitmovinAnalyticsConfig = new BitmovinAnalyticsConfig("<ANALYTICS_KEY>", playerKey, getApplicationContext());
//Step 2: Add optional parameters -> https://gist.github.com/michael-riha/85c5d9629dfc38be9d4c5ad9aaf02a4f
//Step 3: Create Analytics Collector -> https://gist.github.com/michael-riha/85c5d9629dfc38be9d4c5ad9aaf02a4f
...
//Step 4: Attach BitmovinPlayer final step
@michael-riha
michael-riha / AndroidTV-ActivityLicenseHelperSnippet.java
Created January 4, 2019 09:09
Helper to get the PlayerLicenseKey from the Android Manifest for Bitmovin Analytics Android Collector
protected String gePlayerLicenseKey() {
// https://blog.iangclifton.com/2010/10/08/using-meta-data-in-an-androidmanifest/
try {
ApplicationInfo ai = getPackageManager().getApplicationInfo(this.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String playerApiKey = bundle.getString("BITMOVIN_PLAYER_LICENSE_KEY");
return playerApiKey;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to load meta-data, NameNotFound: " + e.getMessage());
} catch (NullPointerException e) {
...
import com.bitmovin.analytics.BitmovinAnalyticsConfig;
import com.bitmovin.analytics.bitmovin.player.BitmovinPlayerCollector;
import com.bitmovin.analytics.enums.CDNProvider;
...
//Step 1: Create your analytics config object
BitmovinAnalyticsConfig bitmovinAnalyticsConfig = new BitmovinAnalyticsConfig("<ANALYTICS_KEY>", "<PLAYER_KEY>", getApplicationContext());
@michael-riha
michael-riha / AndroidTV-ActivityQualitySnippet.java
Created January 4, 2019 08:49
Get the maximum of video quality to display for your viewers
// paste this inside: https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L69
// Do this to get a good startup quality. try to start with a rendition around 12Mbit in this case
playerConfiguration.getAdaptationConfiguration().setStartupBitrate(12_000_000);
@michael-riha
michael-riha / AndroidTV-ActivityControlsSnippet_3.java
Created January 4, 2019 08:42
Handle the main user interaction on Android TV with bitmovin Android SDK (play, pause, seek) - https://github.com/bitmovin/bitmovin-player-android-samples/
// https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L177
this.bitmovinPlayer.play();
// https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L173
this.bitmovinPlayer.pause();
// https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L181-L185
private void stopPlayback()
{
this.bitmovinPlayer.pause();
@michael-riha
michael-riha / AndroidTV-ActivityControlsSnippet_2.java
Created January 4, 2019 08:32
In the handleUserInput method, we pass the code of the key pushed by D-Pad or gamepad - https://github.com/bitmovin/bitmovin-player-android-samples/
//https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L134-L167
private boolean handleUserInput(int keycode)
{
Log.d(TAG, "Keycode " + keycode);
switch (keycode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_NUMPAD_ENTER:
case KeyEvent.KEYCODE_SPACE: