Skip to content

Commit

Permalink
fix() analytics from and to, remove redundant seek analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainPetit1 committed Nov 22, 2022
1 parent bada1ae commit e89ece2
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Sources/ApiVideoPlayer/ApiVideoPlayerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ public class ApiVideoPlayerController: NSObject {
}

private func seekImpl(to time: CMTime, completion: @escaping (Bool) -> Void) {
let from = self.currentTime
self.avPlayer.seek(to: time, toleranceBefore: .zero, toleranceAfter: .zero) { finished in
self.analytics?
.seek(
from: Float(CMTimeGetSeconds(self.currentTime)),
to: Float(CMTimeGetSeconds(time))
from: Float(CMTimeGetSeconds(from)),
to: Float(CMTimeGetSeconds(self.currentTime))
) { result in
switch result {
case .success: break
Expand Down Expand Up @@ -232,13 +233,6 @@ public class ApiVideoPlayerController: NSObject {
public func seek(to: CMTime) {
let from = self.currentTime
self.seekImpl(to: to, completion: { _ in
self.analytics?.seek(from: from, to: self.currentTime) { result in
switch result {
case .success: break
case let .failure(error): print("analytics error seek: \(error)")
}
}

for events in self.events {
events.didSeek?(from, self.currentTime)
}
Expand Down

0 comments on commit e89ece2

Please sign in to comment.