Skip to content

Commit

Permalink
Add multi host livestream
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohsen Mirhoseini committed Nov 9, 2022
1 parent 9415242 commit 137d4c2
Show file tree
Hide file tree
Showing 42 changed files with 678 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This repo holds the Firework Android SDK example applications.
* [Playlist](#playlist-example-app)
* [Shopping](#shopping-example-app)
* [Single-Host Livestream](#single-host-livestream-example-app)
* [Multi-Host Livestream](#multi-host-livestream-example-app)

**Read more about the integration here** https://docs.firework.tv/

Expand Down Expand Up @@ -74,6 +75,18 @@ In this example app, the `VideoFeedView` is initialized for showing single-host

---

## Multi-Host Livestream example app

In this example app, the `VideoFeedView` is initialized for showing multi-host Livestreams.

[Multi-Host Livestream example app](multi_host_livestream)

| Livestream Feed | Livestream Player | Livestream Features |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![multi host livestream Screenshot](multi_host_livestream/Screenshot1.png) | ![multi host livestream Screenshot](multi_host_livestream/Screenshot2.png) | ![multi host livestream Screenshot](multi_host_livestream/Screenshot3.png) |

---

## Shopping example app

In this example app, the `VideoFeedView` is initialized and integrated with the shopping features of the SDK.
Expand Down
44 changes: 44 additions & 0 deletions multi_host_livestream/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SOURCE: https://github.com/github/gitignore/blob/master/Android.gitignore

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
*.ap_
*.aab
*.aar
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store
Binary file added multi_host_livestream/Screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added multi_host_livestream/Screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added multi_host_livestream/Screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions multi_host_livestream/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
69 changes: 69 additions & 0 deletions multi_host_livestream/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "tv.fw.example.multihostlivestream"

compileSdk = 33

defaultConfig {
applicationId = "tv.fw.example.multihostlivestream"

minSdk = 21
targetSdk = 33

versionCode = 1
versionName = "1.0.0"
}

buildTypes {
defaultConfig {
buildConfigField("String", "FW_CLIENT_ID", "\"f6d6ec1275217f178cdff91363825cb390e038c1168f64f6efa23cb95ec6b325\"")
buildConfigField("String", "FW_CHANNEL_ID", "\"o8l83w\"")
buildConfigField("String", "FW_PLAYLIST_ID", "\"g4lA0g\"")
}
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

buildFeatures {
viewBinding = true
}
}

dependencies {
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.6.10"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

// Glide
implementation("com.github.bumptech.glide:glide:4.13.2")

// Firework SDK
val fireworkSdkVersion = "6.0.0-beta.1"
implementation("com.github.loopsocial.firework_sdk_v2:fireworkSdk:$fireworkSdkVersion")

// Glide (optional image loader)
implementation("com.github.loopsocial.firework_sdk_v2:glideImageLoader:$fireworkSdkVersion")

// Picasso (optional image loader)
// implementation("com.github.loopsocial.firework_sdk_v2:picassoImageLoader:$fireworkSdkVersion")

// Livestream player
implementation("com.github.loopsocial.firework_sdk_v2:multihostSupportLivestreamPlayer:$fireworkSdkVersion")
}
21 changes: 21 additions & 0 deletions multi_host_livestream/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
32 changes: 32 additions & 0 deletions multi_host_livestream/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".ExampleApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.FireworkExample"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- this is required by Firework Android SDK v2 to get advertising_id from Android Ad SDK -->
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" />
</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package tv.fw.example.multihostlivestream

import android.app.Application
import android.util.Log
import tv.fw.example.multihostlivestream.BuildConfig.FW_CLIENT_ID
import tv.fw.fireworksdk.FireworkSdk
import tv.fw.fireworksdk.FireworkSdkConfig
import tv.fw.imageloading.glide.GlideImageLoaderFactory
import tv.fw.livestream.multihostsupport.MultihostSupportLivestreamPlayerInitializer

class ExampleApplication : Application() {

override fun onCreate() {
super.onCreate()

// build Firework Android SDK v2 configuration
val config = FireworkSdkConfig.Builder(this)
.checksumRequired(false)
.clientId(FW_CLIENT_ID) // Client OAUTH Id
.userId("example app user ID") // User Id in your eco-system
.imageLoader(GlideImageLoaderFactory.createInstance()) // glide, picasso, or your implementation
.addLivestreamPlayerInitializer(MultihostSupportLivestreamPlayerInitializer()) // Single-Host Livestream and Multi-Host Livestream can be used together, and single-host can be used as a fallback for missing multi-host
.build()

// initialize Firework Android SDK v2
FireworkSdk.init(
fireworkSdkConfig = config,
onSuccess = {
Log.i("FireworkSDK", "Firework SDK initialized successfully")
},
onError = { initError ->
Log.e("FireworkSDK", "Error initializing Firework - $initError")
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tv.fw.example.multihostlivestream

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import tv.fw.common.feed.FeedResource
import tv.fw.example.multihostlivestream.BuildConfig.FW_CHANNEL_ID
import tv.fw.example.multihostlivestream.BuildConfig.FW_PLAYLIST_ID
import tv.fw.example.multihostlivestream.databinding.ActivityMainBinding
import tv.fw.videofeed.options.ViewOptions

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(LayoutInflater.from(this))
setContentView(binding.root)

initVideoFeedView()
}

private fun initVideoFeedView() {
val videoFeedView = binding.videoFeedView

val playlistFeedResource = FeedResource.Playlist(FW_CHANNEL_ID, FW_PLAYLIST_ID)

val viewOptions = ViewOptions.Builder()
.feedResource(playlistFeedResource)
.build()

videoFeedView.init(viewOptions)
}
}
13 changes: 13 additions & 0 deletions multi_host_livestream/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<tv.fw.videofeed.VideoFeedView
android:id="@+id/videoFeedView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions multi_host_livestream/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<resources>
<!-- Base application theme. -->
<style name="Theme.FireworkExample" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
10 changes: 10 additions & 0 deletions multi_host_livestream/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
3 changes: 3 additions & 0 deletions multi_host_livestream/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Firework Multi-Host Livestream Example</string>
</resources>
16 changes: 16 additions & 0 deletions multi_host_livestream/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<resources>
<!-- Base application theme. -->
<style name="Theme.FireworkExample" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
13 changes: 13 additions & 0 deletions multi_host_livestream/app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
10 changes: 10 additions & 0 deletions multi_host_livestream/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "7.3.1" apply false
id("com.android.library") version "7.3.1" apply false
id("org.jetbrains.kotlin.android") version "1.6.10" apply false
}

task<Delete>("clean") {
delete = setOf(rootProject.buildDir)
}
Loading

0 comments on commit 137d4c2

Please sign in to comment.