Created
December 24, 2021 10:59
-
-
Save wowbroforce/9e9e05c986adc71b5ab137814f265791 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// AVMediaCharacteristic+Extensions.swift | |
// | |
// Created by Prokhor Kharchenko. | |
// | |
import AVFoundation | |
import MediaPlayer | |
extension AVMediaSelectionOption { | |
var characteristicString: String { | |
if hasMediaCharacteristic(AVMediaCharacteristic(rawValue: "AVMediaCharacteristicAudible")) { | |
return "Audible" | |
} else if hasMediaCharacteristic(AVMediaCharacteristic(rawValue: "AVMediaCharacteristicLegible")) { | |
return "Legible" | |
} else { | |
return "Other" | |
} | |
} | |
} | |
extension AVMediaSelectionGroup { | |
var characteristicString: String { | |
guard let groupMediaCharacteristics = value(forKey: "_groupMediaCharacteristics") as? [String] else { return "Some" } | |
if groupMediaCharacteristics.contains("AVMediaCharacteristicAudible") { | |
return "Audible" | |
} else if groupMediaCharacteristics.contains("AVMediaCharacteristicLegible") { | |
return "Legible" | |
} else { | |
return "Other" | |
} | |
} | |
} | |
extension MPNowPlayingInfoLanguageOption { | |
var characteristicString: String { | |
if languageOptionCharacteristics?.contains("AVMediaCharacteristicAudible") == true { | |
return "Audible" | |
} else if languageOptionCharacteristics?.contains("AVMediaCharacteristicLegible") == true { | |
return "Legible" | |
} else { | |
return "Other" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment