재생목록 플레이어 추가
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// AudioContentPlaylistManager.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 12/16/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class AudioContentPlaylistManager {
|
||||
private var currentIndex = -1
|
||||
|
||||
let playlist: [AudioContentPlaylistContent]
|
||||
|
||||
init(playlist: [AudioContentPlaylistContent]) {
|
||||
self.playlist = playlist
|
||||
}
|
||||
|
||||
func moveToNext() -> AudioContentPlaylistContent? {
|
||||
if !playlist.isEmpty {
|
||||
currentIndex = currentIndex + 1 >= playlist.count ? 0 : currentIndex + 1
|
||||
return playlist[currentIndex]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func moveToPrevious() -> AudioContentPlaylistContent? {
|
||||
if !playlist.isEmpty {
|
||||
currentIndex = currentIndex - 1 < 0 ? playlist.count - 1 : currentIndex - 1
|
||||
return playlist[currentIndex]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func hasNextContent() -> Bool {
|
||||
return currentIndex + 1 < playlist.count
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user