Skip to content

Commit

Permalink
chore(*): rename player delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Mar 22, 2023
1 parent e436fa8 commit 88b3f7b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class PlayerViewController: UIViewController {

// MARK: PlayerDelegate

extension PlayerViewController: PlayerDelegate {
extension PlayerViewController: ApiVideoPlayerControllerPlayerDelegate {
public func didPrepare() {
print("app didPrepare")
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/ApiVideoPlayer/ApiVideoPlayerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ApiVideoPlayerController: NSObject {
public convenience init(
videoOptions: VideoOptions?,
playerLayer: AVPlayerLayer,
delegates: [PlayerDelegate] = [],
delegates: [ApiVideoPlayerControllerPlayerDelegate] = [],
autoplay: Bool = false
) {
self.init(
Expand All @@ -46,7 +46,7 @@ public class ApiVideoPlayerController: NSObject {
/// - taskExecutor: The executor for the calls to the private session endpoint. Only for test purpose. Default is``TasksExecutor``.
public init(
videoOptions: VideoOptions?,
delegates: [PlayerDelegate] = [],
delegates: [ApiVideoPlayerControllerPlayerDelegate] = [],
autoplay: Bool = false,
taskExecutor: TasksExecutorProtocol.Type = TasksExecutor.self
) {
Expand Down Expand Up @@ -99,26 +99,26 @@ public class ApiVideoPlayerController: NSObject {
/// Adds the provided player delegate.
/// When the delegate is not used anymore, it should be removed with ``removeDelegate(_:)``.
/// - Parameter delegate: The player delegate to be added.
func addDelegate(delegate: PlayerDelegate) {
func addDelegate(delegate: ApiVideoPlayerControllerPlayerDelegate) {
multicastDelegate.addDelegate(delegate)
}

/// Adds the provided player delegates.
/// When the delegates are not used anymore, it should be removed with ``removeDelegate(_:)``.
/// - Parameter delegates: The array of player delegate to be added.
func addDelegates(delegates: [PlayerDelegate]) {
func addDelegates(delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
multicastDelegate.addDelegates(delegates)
}

/// Removes the provided delegate.
/// - Parameter delegate: The player delegate to be removed.
func removeDelegate(delegate: PlayerDelegate) {
func removeDelegate(delegate: ApiVideoPlayerControllerPlayerDelegate) {
multicastDelegate.removeDelegate(delegate)
}

/// Removes the provided delegates.
/// - Parameter delegates: The array of player delegate to be removed.
func removeDelegates(delegates: [PlayerDelegate]) {
func removeDelegates(delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
multicastDelegate.removeDelegates(delegates)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import CoreMedia
import Foundation

public class ApiVideoPlayerControllerMulticastDelegate {
private let multicast = MulticastDelegate<PlayerDelegate>()
private let multicast = MulticastDelegate<ApiVideoPlayerControllerPlayerDelegate>()

init(_ delegates: [PlayerDelegate] = []) {
init(_ delegates: [ApiVideoPlayerControllerPlayerDelegate] = []) {
addDelegates(delegates)
}

func addDelegate(_ delegate: PlayerDelegate) {
func addDelegate(_ delegate: ApiVideoPlayerControllerPlayerDelegate) {
multicast.add(delegate)
}

func addDelegates(_ delegates: [PlayerDelegate]) {
func addDelegates(_ delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
delegates.forEach {
addDelegate($0)
}
}

func removeDelegate(_ delegate: PlayerDelegate) {
func removeDelegate(_ delegate: ApiVideoPlayerControllerPlayerDelegate) {
multicast.remove(delegate)
}

func removeDelegates(_ delegates: [PlayerDelegate]) {
func removeDelegates(_ delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
delegates.forEach {
removeDelegate($0)
}
Expand All @@ -31,7 +31,7 @@ public class ApiVideoPlayerControllerMulticastDelegate {

// MARK: PlayerDelegate

extension ApiVideoPlayerControllerMulticastDelegate: PlayerDelegate {
extension ApiVideoPlayerControllerMulticastDelegate: ApiVideoPlayerControllerPlayerDelegate {

public func didPrepare() {
multicast.invoke {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AVFoundation
import Foundation
/// An interface that delegates of an instance to handle the player events.
public protocol PlayerDelegate: AnyObject {
public protocol ApiVideoPlayerControllerPlayerDelegate: AnyObject {
/// Event called before the video URL will passed to the player.
func didPrepare()
/// Event called when the player is ready to play video.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class SwiftUIPlayerViewController: UIViewController {

}

extension SwiftUIPlayerViewController: PlayerDelegate {
extension SwiftUIPlayerViewController: ApiVideoPlayerControllerPlayerDelegate {
public func didPrepare() {
events?.didPrepare?()
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ApiVideoPlayer/Views/ActionBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ActionBarView: UIView {
}
}

extension ActionBarView: PlayerDelegate {
extension ActionBarView: ApiVideoPlayerControllerPlayerDelegate {
func didPrepare() {}

func didReady() {
Expand Down
8 changes: 4 additions & 4 deletions Sources/ApiVideoPlayer/Views/ApiVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ public class ApiVideoPlayerView: UIView {
/// Adds the provided player delegate.
/// When the delegate is not used anymore, it should be removed with ``removeDelegate(_:)``.
/// - Parameter delegate: The player delegate to be added.
public func addDelegate(_ delegate: PlayerDelegate) {
public func addDelegate(_ delegate: ApiVideoPlayerControllerPlayerDelegate) {
playerController.addDelegate(delegate: delegate)
}

/// Adds the provided player delegates.
/// When the delegates are not used anymore, it should be removed with ``removeDelegate(_:)``.
/// - Parameter delegates: The array of player delegate to be added.
public func addDelegates(_ delegates: [PlayerDelegate]) {
public func addDelegates(_ delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
playerController.addDelegates(delegates: delegates)
}

/// Removes the provided delegate.
/// - Parameter delegate: The player delegate to be removed.
public func removeDelegate(_ delegate: PlayerDelegate) {
public func removeDelegate(_ delegate: ApiVideoPlayerControllerPlayerDelegate) {
playerController.removeDelegate(delegate: delegate)
}

/// Removes the provided delegates.
/// - Parameter delegates: The array of player delegate to be removed.
public func removeDelegates(_ delegates: [PlayerDelegate]) {
public func removeDelegates(_ delegates: [ApiVideoPlayerControllerPlayerDelegate]) {
playerController.removeDelegates(delegates: delegates)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ApiVideoPlayer/Views/ControlsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class ControlsView: UIView {
}
}

extension ControlsView: PlayerDelegate {
extension ControlsView: ApiVideoPlayerControllerPlayerDelegate {
func didPrepare() {}

func didReady() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ApiVideoPlayerTests/Mock/MockedPlayerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MockedPlayerDelegate {

// MARK: PlayerDelegate

extension MockedPlayerDelegate: PlayerDelegate {
extension MockedPlayerDelegate: ApiVideoPlayerControllerPlayerDelegate {
func didPrepare() {
print("test didPrepare")
completedExpectationPrepare?.fulfill()
Expand Down

0 comments on commit 88b3f7b

Please sign in to comment.