
struct VersionedVideo: HtmlProducer {

    let sources: [VideoBlock.Source]

    let options: [VideoBlock.Option]

    func populate(_ result: inout String) {
        result += "<video\(optionString)>Video not supported."
        for source in sources.sorted(using: { $0.type.order }) {
            result += "<source src='\(source.file.absoluteUrl)' type='\(source.type.mimeType)'>"
        }
        result += "</video>"
    }

    private var optionString: String {
        options.map { " " + $0.rawValue }.joined()
    }
}
