Created
April 21, 2021 07:01
-
-
Save KrauserHuang/feb6d4b7d9a46f7d397715965a3f04c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func repeatStateCheck() { | |
switch repeatType { | |
case .none: | |
playingIndex = songs.firstIndex(of: songPlayed!) | |
playingIndex += 1 | |
if playingIndex == songs.count { | |
player.pause() | |
playNPause.setImage(UIImage(systemName: SystemName.playFill), for: .normal) | |
} else { | |
songPlayed = songs[playingIndex] | |
configurePlayer(song: songPlayed!) | |
playerItem = AVPlayerItem(url: songURL) | |
playerLooper = AVPlayerLooper(player: player, templateItem: playerItem!) | |
player.play() | |
} | |
case .whole: | |
playingIndex = songs.firstIndex(of: songPlayed!) | |
playingIndex += 1 | |
if playingIndex == songs.count { | |
playingIndex = 0 | |
} | |
songPlayed = songs[playingIndex] | |
configurePlayer(song: songPlayed!) | |
playerItem = AVPlayerItem(url: songURL) | |
playerLooper = AVPlayerLooper(player: player, templateItem: playerItem!) | |
player.play() | |
case .one: | |
playerItem = AVPlayerItem(url: songURL) | |
playerLooper = AVPlayerLooper(player: player, templateItem: playerItem!) | |
player.play() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment