# Share URL Feed

Share URL Feed displays content from a Firework share URL with a customizable domain. This feed type is perfect for handling deep links, social media shares, and branded URLs.

## Overview

Share URL Feed allows you to open Firework video content using URLs with your custom domain. The SDK reads specific query parameters from the URL to identify and display the correct content. This enables seamless sharing and deep linking experiences with your branded URLs.

## URL Structure

```
https://[your-custom-domain]?fw_video=[video_id]&fw_channel=[channel_id]&fw_playlist=[playlist_id]
```

### URL Components

| Component         | Description                                    | Required       |
| ----------------- | ---------------------------------------------- | -------------- |
| **Domain**        | Your custom domain (e.g., `androidfamily.com`) | Optional\*     |
| **`fw_video`**    | Video content ID                               | ✅ **Required** |
| **`fw_channel`**  | Channel ID                                     | ❌ Optional     |
| **`fw_playlist`** | Playlist ID                                    | ❌ Optional     |

> **Note:** The domain part is completely customizable by your app. The SDK only reads the query parameters (`fw_video`, `fw_channel`, `fw_playlist`).

## Usage

### Required Parameter

* `url` - Share URL with query parameters (required, non-empty)

### Programmatic Configuration

```kotlin
val shareUrl = "https://androidfamily.com?fw_video=o9qYB9&fw_channel=fw_livestream&fw_playlist=oAKXNk"

val viewOptions = viewOptions {
    baseOptions {
        feedResource(
            FeedResource.ShareUrl(url = shareUrl)
        )
    }
    playerOptions {
        showShareButton(true)
    }
}

val videoFeedView = findViewById<FwVideoFeedView>(R.id.videoFeedView)
videoFeedView.init(viewOptions)
```

## Use Cases

* **Deep Link Handling** - Open videos from app deep links
* **Social Media Shares** - Handle URLs shared on social platforms
* **External Referrals** - Links from emails, SMS, or other apps
* **Custom Branded URLs** - Use your own domain for video shares
* **QR Code Integration** - Generate QR codes with video URLs
* **Marketing Campaigns** - Track campaign-specific video links

## Complete Examples

### Deep Link Activity

```kotlin
class DeepLinkActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // Get share URL from intent
        val shareUrl = intent.data?.toString()
        
        if (shareUrl != null && isFireworkShareUrl(shareUrl)) {
            launchVideoFromShareUrl(shareUrl)
        } else {
            // Handle invalid URL
            finish()
        }
    }
    
    private fun isFireworkShareUrl(url: String): Boolean {
        val uri = Uri.parse(url)
        return uri.getQueryParameter("fw_video") != null
    }
    
    private fun launchVideoFromShareUrl(shareUrl: String) {
        val viewOptions = viewOptions {
            baseOptions {
                feedResource(
                    FeedResource.ShareUrl(url = shareUrl)
                )
            }
            playerOptions {
                showShareButton(true)
                showFireworkLogo(false)
            }
        }
        
        // Launch fullscreen player
        FireworkSdk.startPlayer(
            activity = this,
            viewOptions = viewOptions
        )
        
        finish()
    }
}
```

### Share URL Builder

```kotlin
class ShareUrlBuilder {
    companion object {
        private const val BASE_DOMAIN = "https://androidfamily.com"
        
        fun buildShareUrl(
            videoId: String,
            channelId: String? = null,
            playlistId: String? = null
        ): String {
            val params = mutableListOf("fw_video=$videoId")
            
            channelId?.let { params.add("fw_channel=$it") }
            playlistId?.let { params.add("fw_playlist=$it") }
            
            return "$BASE_DOMAIN?${params.joinToString("&")}"
        }
    }
}

// Usage
val shareUrl = ShareUrlBuilder.buildShareUrl(
    videoId = "o9qYB9",
    channelId = "fw_livestream",
    playlistId = "oAKXNk"
)
```

## URL Validation

```kotlin
object FireworkShareUrlValidator {
    fun isValid(url: String): Boolean {
        return try {
            val uri = Uri.parse(url)
            // fw_video is required
            val videoId = uri.getQueryParameter("fw_video")
            !videoId.isNullOrEmpty()
        } catch (e: Exception) {
            false
        }
    }
    
    fun extractVideoId(url: String): String? {
        return try {
            Uri.parse(url).getQueryParameter("fw_video")
        } catch (e: Exception) {
            null
        }
    }
    
    fun extractChannelId(url: String): String? {
        return try {
            Uri.parse(url).getQueryParameter("fw_channel")
        } catch (e: Exception) {
            null
        }
    }
    
    fun extractPlaylistId(url: String): String? {
        return try {
            Uri.parse(url).getQueryParameter("fw_playlist")
        } catch (e: Exception) {
            null
        }
    }
}
```

## URL Examples

### Minimum Required (Video Only)

```
https://androidfamily.com?fw_video=o9qYB9
```

### With Channel

```
https://androidfamily.com?fw_video=o9qYB9&fw_channel=fw_livestream
```

### Complete (Video + Channel + Playlist)

```
https://androidfamily.com?fw_video=o9qYB9&fw_channel=fw_livestream&fw_playlist=oAKXNk
```

### Custom Domain Examples

```
https://yourbrand.com?fw_video=abc123
https://videos.myapp.com?fw_video=xyz789&fw_channel=main_channel
https://share.example.com?fw_video=def456&fw_channel=featured&fw_playlist=highlights
```

## Important Notes

* **Custom Domain** - Use any domain you control for branding
* **Required Parameter** - `fw_video` query parameter is **mandatory**
* **Optional Parameters** - `fw_channel` and `fw_playlist` are optional
* **Empty String Exception** - Empty URL will throw an exception
* **URL Validation** - Validate URL structure before using
* **Deep Link Setup** - Configure Android App Links for seamless experience
* **HTTPS Recommended** - Use HTTPS for security

## Android App Links Setup

For seamless deep linking, set up Android App Links:

1. **Add intent filter** in AndroidManifest.xml (see example above)
2. **Configure assetlinks.json** on your web server
3. **Enable autoVerify** in intent filter

Refer to [Android App Links documentation](https://developer.android.com/training/app-links) for detailed setup.

## See Also

* [Feed Sources Overview](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/feed-sources) - All available feed types
* [Single Content Feed](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/feed-sources/single-content-feed) - Display specific videos
* [BaseOption Configuration](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/configuration/base-options) - Detailed configuration
* [FireworkSdk.startPlayer](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/fullscreen-player) - Fullscreen player
* [Video Deep Linking](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/video-deep-linking) - Deep link configuration
