Skip to content

Commit

Permalink
Fix media tracking calls not being dispatched on the correct queue wh…
Browse files Browse the repository at this point in the history
…en tracking using AVPlayer
  • Loading branch information
matus-tomlein committed Aug 19, 2024
1 parent 20b1fea commit f4285f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Integrationtests/TestTrackEventsToMicro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import XCTest
import SnowplowTracker
#if !os(watchOS)
import AVKit
#endif

class TestTrackEventsToMicro: XCTestCase {
var tracker: TrackerController?
Expand Down Expand Up @@ -166,6 +169,16 @@ class TestTrackEventsToMicro: XCTestCase {
], timeout: Micro.timeout)
}

#if !os(watchOS)
func testMediaTrackingUsingAVPlayer() {
let player = AVPlayer()
let mediaTracking = tracker?.media.startMediaTracking(player: player, configuration: MediaTrackingConfiguration(id: "integration-test"))
mediaTracking?.track(MediaReadyEvent())

wait(for: [Micro.expectCounts(good: 1)], timeout: Micro.timeout)
}
#endif

private func track(_ event: Event) {
_ = tracker!.track(event)
tracker!.emitter!.flush()
Expand Down
4 changes: 3 additions & 1 deletion Sources/Core/InternalQueue/MediaControllerIQWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class MediaControllerIQWrapper: MediaController {
#if !os(watchOS)
func startMediaTracking(player: AVPlayer,
configuration: MediaTrackingConfiguration) -> MediaTracking {
return InternalQueue.sync { controller.startMediaTracking(player: player, configuration: configuration) }
return InternalQueue.sync {
MediaTrackingIQWrapper(tracking: controller.startMediaTracking(player: player, configuration: configuration))
}
}
#endif

Expand Down

0 comments on commit f4285f8

Please sign in to comment.