Social Link
This guide explains how to handle social media link click events in the Firework SDK.
Overview
When a video contains external media sources from TikTok, Instagram, or YouTube, the SDK displays corresponding social media icons and usernames on the video. When users click these links, you can:
Custom Handling: Open native apps, log analytics data, or execute other business logic
Default Handling: Let the SDK open the link in the browser
Quick Start
Setting Up the Listener
Set up the listener after SDK initialization (typically in Application or MainActivity):
import com.firework.sdk.FireworkSdk
import com.firework.player.common.social.SocialLinkInfo
import com.firework.player.common.social.SocialPlatform
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set up social link click listener
setupSocialLinkClickListener()
}
private fun setupSocialLinkClickListener() {
FireworkSdk.social.setOnVideoSocialLinkClickListener { info ->
// info contains all click-related information
Log.d("Firework", "Social link clicked: ${info.platform}")
when (info.platform) {
SocialPlatform.TIKTOK -> {
// Custom handling for TikTok links
openTikTokApp(info.username, info.url)
true // Return true to indicate you've handled it
}
SocialPlatform.INSTAGRAM -> {
// Custom handling for Instagram links
openInstagramApp(info.username, info.url)
true
}
SocialPlatform.YOUTUBE -> {
// Custom handling for YouTube links
openYouTubeApp(info.url)
true
}
SocialPlatform.UNKNOWN -> {
// Return false to let SDK open in default browser
false
}
}
}
}
override fun onDestroy() {
// Clean up the listener
FireworkSdk.social.setOnVideoSocialLinkClickListener(null)
super.onDestroy()
}
}Callback Parameters
SocialLinkInfo
videoId
String
Unique identifier of the current video
url
String
Target URL of the social media link
username
String?
Social media username (may be null)
platform
SocialPlatform
Social platform type
videoInfo
VideoInfo
Detailed video information for analytics
SocialPlatform
TIKTOK
TikTok platform
INSTAGRAM
Instagram platform
YOUTUBE
YouTube platform
UNKNOWN
Unknown platform
VideoInfo
Provides complete video context for analytics and tracking:
id
String
Video ID
caption
String
Video title
duration
Double
Video duration in seconds
badge
String?
Video badge label (e.g., "ad")
playerHeight
Int?
Player height in pixels
playerWidth
Int?
Player width in pixels
hasCta
Boolean
Whether the video has a call-to-action
isAd
Boolean
Whether the video is an ad (deprecated, use videoType == VideoType.Ad)
hashtags
List<String>
Hashtags associated with the video
feedType
String
Feed type identifier
channelId
String?
Channel ID
playlistId
String?
Playlist ID
feedId
String
Feed ID
videoType
VideoType
Video type (see below)
autoPlay
Boolean?
Whether the video was auto-played
ctaLabel
String?
Video CTA label, when available.
ctaActionUrl
String?
Video CTA target URL, when available.
ctaActionType
String?
Video CTA action type, when available.
VideoType
A sealed interface representing the type of video content:
VideoType.ShortVideo
Short-form video
VideoType.Ad
Advertisement video
VideoType.Livestream.Idle
Livestream that hasn't started yet
VideoType.Livestream.Live
Livestream currently live
VideoType.Livestream.Replay
Livestream replay
VideoType.Livestream.Completed
Livestream that has ended
Return Value
The callback function must return a Boolean value:
true
You've handled the click event; SDK will not take any action
false
SDK will open the URL in the system's default browser
Customize Social Link Text Style
Social link click handling is configured through FireworkSdk.social. Social link visual styling is configured through ViewOptions.
Use PlayerOption.socialLinkStyle to customize social/sponsor link text in the fullscreen player:
Use PlayerDeckOption.socialLinkStyle to customize social/sponsor link text in the inline FwPlayerDeckView player:
fontSizeSp and fontWeight are optional. fontWeight uses Android numeric font weight values from 1 to 1000; common values include 400 for regular, 600 for semibold, and 700 for bold.
If socialLinkStyle is null, or if a SocialLinkStyle field is null, the SDK keeps the default style for that field. The effective SDK defaults are 12sp text size and 400 font weight. The social link start icon scales with the text height.
For the full option references, see PlayerOption and PlayerDeckOption.
Best Practices
1. Clean Up Listeners
Remove the listener when Activity or Fragment is destroyed to avoid memory leaks:
2. Handle App Not Installed
Always handle ActivityNotFoundException when trying to open native apps:
FAQ
Q: What happens if I don't set a listener?
The SDK will use the default behavior and open the link in the system browser.
Q: Can I set listeners in multiple places?
No. Each call to setOnVideoSocialLinkClickListener replaces the previous listener.
Q: Which thread does the callback run on?
The callback runs on the main thread (UI thread), so you can directly update the UI.
Q: How can I get more video information?
info.videoInfo contains complete video context including title, duration, channel, and more.
API Reference
Support
If you have any questions, please contact the Firework technical support team.
Last updated
Was this helpful?