Skip to content

Commit

Permalink
add playing start callback closure
Browse files Browse the repository at this point in the history
  • Loading branch information
nerd0geek1 committed Oct 6, 2016
1 parent cd38321 commit e8ecd72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PlayListPlayer/classes/player/PlayListPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class PlayListPlayer: PlayListPlayerType {

public static let sharedInstance: PlayListPlayer = PlayListPlayer()

public var didStartPlayingTrack:(() -> Void)?
public var didFinishPlayingTrack:(() -> Void)?
public var didFinishPlayingPlayList:(() -> Void)?

Expand Down Expand Up @@ -141,6 +142,7 @@ public class PlayListPlayer: PlayListPlayerType {

public func seekToBeginning() {
seekTo(0)
didStartPlayingTrack?()
}

public func seekTo(position: Float) {
Expand Down Expand Up @@ -170,6 +172,7 @@ public class PlayListPlayer: PlayListPlayerType {

let playerItem: AVPlayerItem = AVPlayerItem(URL: url)
player.replaceCurrentItemWithPlayerItem(playerItem)
didStartPlayingTrack?()

NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(playerDidFinishTrackPlaying),
Expand Down
1 change: 1 addition & 0 deletions PlayListPlayer/classes/player/PlayListPlayerType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AVFoundation

public protocol PlayListPlayerType {

var didStartPlayingTrack:(() -> Void)? { get set }
var didFinishPlayingTrack:(() -> Void)? { get set }
var didFinishPlayingPlayList:(() -> Void)? { get set }

Expand Down

0 comments on commit e8ecd72

Please sign in to comment.