I am not an IOS programmer but I need a simple app to play an audio stream from a wowza server. Here is my code, I get no errors but also no audio. Any guidances or help?
import UIKit
import AVFoundation
class ViewController: UIViewController {
var player = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
var fileURL: NSURL = NSURL(string: "http://url----.com/playlist.m3u8")
var error:NSError?
player = AVAudioPlayer(contentsOfURL: fileURL, error: &error)
if player.prepareToPlay() && player.play(){
println("yes")
} else {
println("no")
}
}
This worked for me:
var player = AVPlayer()
func configureView() {
let url = "http://stream.your.url.com"
let playerItem = AVPlayerItem( URL:NSURL( string:url ) )
player = AVPlayer(playerItem:playerItem)
player.rate = 1.0;
player.play()
}