The problem is that Player
, your AVAudioPlayer, is a local variable. So it goes out of existence immediately – before it can even start playing, let alone finish playing.
Solution: make it a property instead, so that it will persist.
More Related Contents:
- Read a file/URL line-by-line in Swift
- How to play audio in background with Swift?
- Swift – Capture keydown from NSViewController
- CommonHMAC in Swift
- Getting Mouse Coordinates in Swift
- dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib
- Using NSURLSession from a Swift command line program
- OSX application without storyboard or xib files using Swift
- Writing a String to an NSOutputStream in Swift
- Adjust screen brightness in Mac OS X app
- Getting alias path of file in swift
- Using existing system sounds in iOS App [swift|
- AVFoundation (AVPlayer) supported formats? No .vob or .mpg containers?
- Use of unresolved identifier ‘UIScreen’; did you mean ‘NSScreen’? DynamicTypes works fine on iOS, but it doesn’t on macOS
- Problems getting pygame to show anything but a blank screen on Macos
- npm global path prefix
- Build Multiarch OpenSSL on OS X
- How to completely uninstall VS Code on mac?
- How to hide the Dock icon
- Is there a way to install gcc in OSX without installing Xcode?
- How do I create a Bash alias?
- Error: The ‘brew link’ step did not complete successfully
- How to trace system calls of a program in Mac OS X?
- How do I increase the stack size when compiling with Clang on OS X?
- Where are core dumps written on Mac?
- How to make OS X to read .bash_profile not .profile file
- Is there a IE tester for mac? [closed]
- AVAudioEngine downsample issue
- Where can I find “make” program for Mac OS X Lion?
- macOS SwiftUI Navigation for a Single View