Skip to content

Commit

Permalink
[CORE-5162] Changes requested by @StefanoStream
Browse files Browse the repository at this point in the history
  • Loading branch information
KharchenkoAlex committed Nov 21, 2024
1 parent 6fcd407 commit 7878a78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Sources/PlaybackSDK/PlayBackSDKManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ public class PlayBackSDKManager {
entryID: String,
authorizationToken: String? = nil,
mediaTitle: String? = nil,
userId: String? = nil,
viewerId: String? = nil,
onError: ((PlayBackAPIError) -> Void)?
) -> some View {

PlaybackUIView(
entryId: entryID,
authorizationToken: authorizationToken,
mediaTitle: mediaTitle,
userId: userId,
viewerId: viewerId,
onError: onError
)
.id(entryID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ public class BitmovinPlayerPlugin: VideoPlayerPlugin {
playerConfig.styleConfig.userInterfaceConfig = uiConfig
}

private func createAnalyticsConfig(userId: String? = nil) -> AnalyticsPlayerConfig {
private func createAnalyticsConfig(viewerId: String? = nil) -> AnalyticsPlayerConfig {
guard let licenseKey = PlayBackSDKManager.shared.bitmovinLicense else {
return .disabled
}
let defaultMetadata = DefaultMetadata(cdnProvider: "PlaybackSDK", customUserId: userId)
let defaultMetadata = DefaultMetadata(cdnProvider: "PlaybackSDK", customUserId: viewerId)
let analytics: BitmovinPlayerAnalytics.AnalyticsPlayerConfig = licenseKey != nil
? .enabled(analyticsConfig: AnalyticsConfig(licenseKey: licenseKey), defaultMetadata: defaultMetadata)
: .disabled
return analytics
}

public func playerView(hlsURLString: String, title: String = "", userId: String? = nil) -> AnyView {
public func playerView(hlsURLString: String, title: String = "", viewerId: String? = nil) -> AnyView {

// Create player based on player and analytics configurations
let player = PlayerFactory.createPlayer(
playerConfig: playerConfig,
analytics: self.createAnalyticsConfig(userId: userId)
analytics: self.createAnalyticsConfig(viewerId: viewerId)
)

self.player = player
Expand Down
2 changes: 1 addition & 1 deletion Sources/PlaybackSDK/Player Plugin/VideoPlayerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public protocol VideoPlayerPlugin: AnyObject {
// TODO: add event
/// func handleEvent(event: BitmovinPlayerCore.PlayerEvent)

func playerView(hlsURLString: String, title: String, userId: String?) -> AnyView
func playerView(hlsURLString: String, title: String, viewerId: String?) -> AnyView

func play()

Expand Down
8 changes: 4 additions & 4 deletions Sources/PlaybackSDK/PlayerUIView/PlaybackUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal struct PlaybackUIView: View {
private var authorizationToken: String?

/// Optional user ID to be tracked in analytics
private var userId: String?
private var viewerId: String?

/// Observed object to manage the video player plugins.
@ObservedObject private var pluginManager = VideoPlayerPluginManager.shared
Expand All @@ -43,12 +43,12 @@ internal struct PlaybackUIView: View {
- entryId: The entry ID of the video to be played.
- authorizationToken: Optional authorization token if required to fetch the video details.
*/
internal init(entryId: String, authorizationToken: String?, mediaTitle: String?, userId: String?, onError: ((PlayBackAPIError) -> Void)?) {
internal init(entryId: String, authorizationToken: String?, mediaTitle: String?, viewerId: String?, onError: ((PlayBackAPIError) -> Void)?) {
self.entryId = entryId
self.authorizationToken = authorizationToken
self.onError = onError
self.mediaTitle = mediaTitle
self.userId = userId
self.viewerId = viewerId
}

/// The body of the view.
Expand All @@ -62,7 +62,7 @@ internal struct PlaybackUIView: View {
} else {
if let videoURL = videoURL {
if let plugin = pluginManager.selectedPlugin {
plugin.playerView(hlsURLString: videoURL.absoluteString, title: self.mediaTitle ?? "", userId: self.userId)
plugin.playerView(hlsURLString: videoURL.absoluteString, title: self.mediaTitle ?? "", viewerId: self.viewerId)
} else {
ErrorUIView(errorMessage: "No plugin selected")
.background(Color.white)
Expand Down

0 comments on commit 7878a78

Please sign in to comment.