Add single file audio player, introduce blocks

This commit is contained in:
Christoph Hagen
2025-01-06 01:17:06 +01:00
parent c78c359819
commit 245534e989
27 changed files with 521 additions and 88 deletions

View File

@ -0,0 +1,49 @@
import Foundation
final class AudioPlayerSettings: ObservableObject {
@Published
var playlistCoverImageSize: Int
@Published
var smallCoverImageSize: Int
@Published
var audioPlayerJsFile: FileResource?
@Published
var audioPlayerCssFile: FileResource?
init(playlistCoverImageSize: Int,
smallCoverImageSize: Int,
audioPlayerJsFile: FileResource?,
audioPlayerCssFile: FileResource?) {
self.playlistCoverImageSize = playlistCoverImageSize
self.smallCoverImageSize = smallCoverImageSize
self.audioPlayerJsFile = audioPlayerJsFile
self.audioPlayerCssFile = audioPlayerCssFile
}
init(file: AudioPlayerSettingsFile, files: [String : FileResource]) {
self.playlistCoverImageSize = file.playlistCoverImageSize
self.smallCoverImageSize = file.smallCoverImageSize
self.audioPlayerJsFile = file.audioPlayerJsFile.map { files[$0] }
self.audioPlayerCssFile = file.audioPlayerCssFile.map { files[$0] }
}
var file: AudioPlayerSettingsFile {
.init(playlistCoverImageSize: playlistCoverImageSize,
smallCoverImageSize: smallCoverImageSize,
audioPlayerJsFile: audioPlayerJsFile?.id,
audioPlayerCssFile: audioPlayerCssFile?.id)
}
}
extension AudioPlayerSettings {
static let `default`: AudioPlayerSettings = .init(
playlistCoverImageSize: 280,
smallCoverImageSize: 78,
audioPlayerJsFile: nil,
audioPlayerCssFile: nil)
}