Skip to content

Add UIKit and SwiftUI AVPlayer examples - #3

Open
rohit-fastpix wants to merge 1 commit into
mainfrom
examples/avplayer-swiftui
Open

Add UIKit and SwiftUI AVPlayer examples#3
rohit-fastpix wants to merge 1 commit into
mainfrom
examples/avplayer-swiftui

Conversation

@rohit-fastpix

Copy link
Copy Markdown
Collaborator

FastPix Video Data AVPlayer SDK — Examples PR

Changes

What Changed

  • New documentation added (per-example READMEs)
  • Existing documentation updated
  • Documentation errors fixed
  • Code examples updated (added runnable example apps)
  • Links and references updated
  • New example apps added (UIKit + SwiftUI)

Files Modified

  • README.md
  • docs/ files
  • USAGE.md
  • CONTRIBUTING.md
  • Other:
    • example/Examples/UIKit/ — existing UIKit example moved and repointed
      at the SDK as a local Swift package (../..); removed hardcoded signing
      team so it builds on a bare Simulator
    • Examples/SwiftUI/ — new SwiftUI (VideoPlayer) example (iOS 16+)
    • Examples/README.md, Examples/UIKit/README.md, Examples/SwiftUI/README.md
    • .gitignore

Summary

Brief description of changes:

Reorganizes the existing UIKit example into Examples/UIKit/ and adds a new
SwiftUI example under Examples/SwiftUI/, so the repo demonstrates the AVPlayer
data SDK in both UI paradigms. Both projects reference the SDK as a local Swift
package, so they build against this checkout with no network fetch, and both were
verified building and running on the iOS Simulator. Adds a short top-level
Examples/README.md plus a per-project README for each, and a .gitignore for
Xcode/SwiftPM artifacts. No changes to the SDK source or the main README.

Code Examples

import AVKit
import FastpixVideoDataAVPlayer

let player = AVPlayer(url: streamURL)

// Initialize the SDK for tracking AVPlayer analytics
let fpDataSDK = initAvPlayerTracking()

// All metadata fields live under the "data" key
let customMetadata: [String: Any] = [
    "data": [
        "workspace_id": "WORKSPACE_KEY",   // Replace with your actual workspace key
        "video_title": "Test Content",     // Title of the video being played
        "video_id": "f01a98s76t90p88i67x", // Unique identifier for the video
        "viewer_id": "user12345",          // Unique viewer identifier
        "video_content_type": "series",    // Content type (e.g., series, movie)
        "video_stream_type": "on-demand",  // Stream type (live/on-demand)
        "custom_1": "",                    // Custom metadata field 1
        "custom_2": ""                     // Custom metadata field 2
    ]
]

// Track an AVPlayer (pass the AVPlayerLayer if you have one, else nil).
// The SDK observes the player automatically (KVO + notifications), so
// play / pause / seeking / buffering / ended are dispatched for you.
fpDataSDK.trackAvPlayer(
    player: player,
    playerLayer: nil,
    customMetadata: customMetadata
)

// Or track an AVPlayerViewController:
fpDataSDK.trackAvPlayerController(
    playerController: playerViewController,
    customMetadata: customMetadata
)

// Or track an AVPlayerLayer:
fpDataSDK.trackAvPlayerLayer(
    playerLayer: playerLayer,
    customMetadata: customMetadata
)

// On a new video in the same player (playlist / series):
fpDataSDK.dispatchEvent(event: "videoChange", metadata: [
    "video_id": "123def",
    "video_title": "Daalcheeni",
    "video_series": "Comedy Capsule"
])

Testing

  • All code examples tested on iOS (both example apps build + run on Simulator)
  • Links verified
  • Grammar checked
  • Formatting consistent

Review Checklist

  • Content is accurate
  • Code examples work as expected
  • Links are working
  • Grammar is correct
  • Formatting is consistent

Ready for review!

Rename example/ to Examples/UIKit, point it at the local package, and add a SwiftUI example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant