@@ -8,8 +8,7 @@ import MediaPlayer
8
8
/// It is used internally of the ``ApiVideoPlayerView``.
9
9
/// It could be used directly if you want to use the player with a fully custom UI.
10
10
public class ApiVideoPlayerController : NSObject {
11
- internal let player = AVPlayer ( playerItem: nil )
12
- private var analytics : PlayerAnalytics ?
11
+ internal let player = ApiVideoAnalyticsAVPlayer ( playerItem: nil )
13
12
private var timeObserver : Any ?
14
13
private var isFirstPlay = true
15
14
private var isSeeking = false
@@ -163,9 +162,7 @@ public class ApiVideoPlayerController: NSObject {
163
162
name: . AVPlayerItemDidPlayToEndTime,
164
163
object: playerItem
165
164
)
166
- if let urlAsset = playerItem. asset as? AVURLAsset {
167
- self . setUpAnalytics ( url: urlAsset. url. absoluteString)
168
- }
165
+
169
166
}
170
167
171
168
private func notifyError( error: Error ) {
@@ -209,15 +206,6 @@ public class ApiVideoPlayerController: NSObject {
209
206
player. removeTimeObserver ( observer)
210
207
}
211
208
212
- private func setUpAnalytics( url: String ) {
213
- do {
214
- let option = try Options ( mediaUrl: url)
215
- self . analytics = PlayerAnalytics ( options: option)
216
- } catch {
217
- print ( " Failed to initiate analytics for \( url) " )
218
- }
219
- }
220
-
221
209
/// Get if the player is playing a live stream.
222
210
/// - Returns: True if the player is playing a live stream
223
211
public var isLive : Bool {
@@ -253,16 +241,6 @@ public class ApiVideoPlayerController: NSObject {
253
241
private func seekImpl( to time: CMTime , completion: @escaping ( Bool ) -> Void ) {
254
242
let from = self . currentTime
255
243
self . player. seek ( to: time, toleranceBefore: . zero, toleranceAfter: . zero) { completed in
256
- self . analytics?
257
- . seek (
258
- from: Float ( max ( 0 , from. seconds) ) ,
259
- to: Float ( max ( 0 , time. seconds) )
260
- ) { result in
261
- switch result {
262
- case . success: break
263
- case let . failure( error) : print ( " Failed to send seek event to analytics: \( error) " )
264
- }
265
- }
266
244
self . infoNowPlaying. updateCurrentTime ( currentTime: time)
267
245
completion ( completed)
268
246
}
@@ -514,12 +492,6 @@ public class ApiVideoPlayerController: NSObject {
514
492
self . replay ( )
515
493
self . multicastDelegate. didLoop ( )
516
494
}
517
- self . analytics? . end { result in
518
- switch result {
519
- case . success: break
520
- case let . failure( error) : print ( " Failed to send end event to analytics: \( error) " )
521
- }
522
- }
523
495
self . multicastDelegate. didEnd ( )
524
496
}
525
497
@@ -578,12 +550,6 @@ public class ApiVideoPlayerController: NSObject {
578
550
if self . autoplay {
579
551
self . play ( )
580
552
}
581
- self . analytics? . ready { result in
582
- switch result {
583
- case . success: break
584
- case let . failure( error) : print ( " Failed to send ready event to analytics: \( error) " )
585
- }
586
- }
587
553
}
588
554
}
589
555
@@ -596,12 +562,6 @@ public class ApiVideoPlayerController: NSObject {
596
562
return
597
563
}
598
564
599
- self . analytics? . pause { result in
600
- switch result {
601
- case . success: break
602
- case let . failure( error) : print ( " Failed to send pause event to analytics: \( error) " )
603
- }
604
- }
605
565
self . infoNowPlaying. pause ( currentTime: self . currentTime)
606
566
self . multicastDelegate. didPause ( )
607
567
}
@@ -623,19 +583,7 @@ public class ApiVideoPlayerController: NSObject {
623
583
)
624
584
625
585
#endif
626
- self . analytics? . play { result in
627
- switch result {
628
- case . success: break
629
- case let . failure( error) : print ( " Failed to send play event to analytics: \( error) " )
630
- }
631
- }
632
586
} else {
633
- self . analytics? . resume { result in
634
- switch result {
635
- case . success: break
636
- case let . failure( error) : print ( " Failed to send resume event to analytics: \( error) " )
637
- }
638
- }
639
587
self . infoNowPlaying. play ( currentTime: self . currentTime)
640
588
}
641
589
#if !os(macOS)
0 commit comments