File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
WooCommerce/Classes/POS/Utils/Audio Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,9 @@ protocol PointOfSaleSoundPlayerProtocol {
1414 func playSound( _ sound: PointOfSaleSound ) async
1515}
1616
17- final class PointOfSaleSoundPlayer : PointOfSaleSoundPlayerProtocol {
18- private var audioPlayer : AVAudioPlayer ?
17+ actor PointOfSaleSoundPlayer : PointOfSaleSoundPlayerProtocol {
1918 private var playerCache : [ PointOfSaleSound : AVAudioPlayer ] = [ : ]
2019
21- @MainActor
2220 func playSound( _ sound: PointOfSaleSound ) async {
2321 guard let url = Bundle . main. url ( forResource: sound. name, withExtension: sound. type) else {
2422 DDLogError ( " Sound file not found: \( sound. name) . \( sound. type) " )
@@ -34,9 +32,9 @@ final class PointOfSaleSoundPlayer: PointOfSaleSoundPlayerProtocol {
3432 }
3533
3634 do {
37- audioPlayer = try AVAudioPlayer ( contentsOf: url)
38- audioPlayer? . prepareToPlay ( )
39- audioPlayer? . play ( )
35+ let audioPlayer = try AVAudioPlayer ( contentsOf: url)
36+ audioPlayer. prepareToPlay ( )
37+ audioPlayer. play ( )
4038 playerCache [ sound] = audioPlayer
4139 } catch {
4240 DDLogError ( " Failed to play sound: \( error) " )
You can’t perform that action at this time.
0 commit comments