Audio

public enum Audio
extension Audio: CustomStringConvertible
extension Audio: RawRepresentable
extension Audio: MediaSubtype
extension Audio: Hashable

Represents the audio media type. See the official documentation for details.

You typically use Audio as a MediaType.

let audio = Audio.ac3(nil, ["rate": 32000])
let mediaType = MediaType.audio(audio) // Creates: audio/ac3;rate=32000

You can use standard switch statement to access audio values.

func isSupported(audio: Audio) -> Bool {
  switch audio {
  case .ac3, .aac, .ogg: return true
  default: return false
  }
}

isSupported(audio: .ac3()) // Returns: true
isSupported(audio: .aac()) // Returns: true
isSupported(audio: .ogg()) // Returns: true
isSupported(audio: .mpeg()) // Returns: false

See also

MediaType