Reputation: 609
Xcode Version - 6.1.1, IOS Version on Device(IPHONE 4S) - 8.1.2
class ViewController2: UIViewController,AVAudioPlayerDelegate {
var player: AVPlayer! = nil
override func viewDidLoad() {
super.viewDidLoad()
var steamingURL:NSURL! = NSURL(string:"http://yflvr.com:8080/data/songs1/mp3/16287239.mp3")
player = AVPlayer(URL: steamingURL)
player.play()
}
}
Upvotes: 2
Views: 1561
Reputation: 9716
Check the spelling of your filename. The device is case-sensitive, the simulator is not... Are you sure it is not just delayed?
Also, check if your ringer is off, you won't hear any sound when it's off. To prevent that, use
var session: AVAudioSession = AVAudioSession.sharedInstance();
session.setCategory(AVAudioSessionCategoryPlayback, error: nil)
from here
You can also set an observer on the AVPlayer.status property to debug its changing status
Here they have used AVAudioPlayer and added a call to prepareToPlay()
Upvotes: 5