Video Deep linking

Customise base Share URL

By default the share url of the firework videos have the firework base URL - https://fw.tv. For example share url can look like this:

https://fw.tv/videos/xxxx?fw_channel=someChannel&fw_video=somevideoId

If you want to replace the Firework base URL in share link, just provide a base URL you want in PlayerOptions:

val viewOptions = ViewOptions.Builder().playerOption(
   PlayerOption.Builder()
        .shareBaseUrl("https://www.example.com")
        .build()
).build()

// Or DSL verison: 

val viewOptions = viewOptions {
   playerOptions{
      shareBaseUrl("https://www.example.com")
   }
}

fwVideoFeedView.init(viewOptions)

Deep linking

If you are new to the concept of deep linking, please read the official android documentation first: https://developer.android.com/training/app-links/deep-linking To handle the universal link ( shared url ) in your app, you need to add Intent filter to the activity that should handle the deep link:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https" android:host="example.com" />
</intent-filter>

When a user clicks on the shared URL, the activity is launched. You can use the following function in the onCreate() method of the activity to check if the activity is launched via deep link:

fun isOpenedViaDeepLink(intent: Intent): Boolean {
    val uri: Uri? = intent.data
    if (uri == null) {
        return false
    }
    val isValidScheme = (uri.scheme ?: "") in listOf("http", "https")
    val isDeeplinkHost = uri.host == "example.com"
    return isValidScheme && isDeeplinkHost
}

If activity is launched via deep link, next step is to launch the player. For this purpose use the following code:

val url = intent.data!!.toString
val launchResult = FireworkSdk.startPlayer(viewOptions = viewOptions, url = url)
if(launchResult is PlayerLaunchResult.Failure) {
  // Handle error
}

Use the following link to read more about ViewOptions: Configure Video Feed. FireworkSdk.startPlayer() returns result which indicates if url can be opened by the SDK or not.

Keep in mind that FireworkSdk should be initialised before calling FireworkSdk.startPlayer() function.

Note: Starting in Android 12 (API level 31), a generic web intent resolves to an activity in your app only if your app is approved for the specific domain contained in that web intent. If your app isn't approved for the domain, the web intent resolves to the user's default browser app instead.

Last updated