Here's my current ViewController:
import UIKit
import AVFoundation
class SecondViewController: UIViewController {
override func viewDidLoad() {
var player = AVPlayer()
let url = "http://www.nasa.gov/mp3/640149main_Computers%20are%20in%20Control.mp3"
let playerItem = AVPlayerItem( URL:NSURL( string:url ) )
player = AVPlayer(playerItem:playerItem)
player.rate = 1.0;
player.play()
}
}
When I run this in the simulator I get no audio, could it be that the iOS sim doesn't play audio, or an issue with my code?
Move the line:
var player = AVPlayer()
... so that it is before the line:
override func viewDidLoad() {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With