IOS 8 Swift AVAudioPlayer play remote audio (wowza server)

avplayer swift 4 example
play audio from url swift 4
avplayer streaming audio swift
swift audio player
avaudioplayer not playing swift
swift play audio in background
swift play sound on button press
stream audio swift

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()

}

Ios avaudioplayer streaming, 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  The AVAudioPlayer class, which is part of the AVFoundation framework, provides a simple way to play audio from within iOS applications. In addition to playing back audio, the class also provides a number of methods that can be used to control the playback in terms of starting, stopping and changing the volume of the playback.

In Swift 2.0 and iOS 9

do {
    let url = "http://yourdomain.com/file.mp3"
    let fileURL = NSURL(string:url)
    let soundData = NSData(contentsOfURL:fileURL!)
    self.audioPlayer = try AVAudioPlayer(data: soundData!)
    audioPlayer.prepareToPlay()
    audioPlayer.volume = 1.0
    audioPlayer.delegate = self
    audioPlayer.play()
} catch {
    print("Error getting the audio file")
}

How to set up video streaming in your app with AVPlayer, I'm successfully using AVAudioPlayer to play and pause audio from a server play audio, xcode play audio, stream audio ios swift, audio player swift github, ios is for playing local media, and AVPlayer is for streaming from a remote server, IOS 8 Swift AVAudioPlayer play remote audio (wowza server) Ask Question. Plays a sound asynchronously, starting at a specified point in the audio output device’s timeline. func pause () Pauses playback; sound remains ready to resume playback from where it left off.

This anwser helped me: AVAudioPlayer with external URL to *.m4p

I had to convert thr URL to NSData:

let url = "http://megdadhashem.wapego.ru/files/56727/tubidy_mp3_e2afc5.mp3"
let fileURL = NSURL(string:url)
let soundData = NSData.dataWithContentsOfURL(fileURL, options: nil, error: nil)
var error: NSError?
self.player = AVAudioPlayer(data: soundData, error: &error)
if player == nil {
  if let e = error {
    println(e.localizedDescription)
  }
}
player.prepareToPlay()
player.volume = 1.0
player.delegate = self
player.play()

setup MPRemoteCommandCenter in watchOS Now Playing with , To create a video player, we'll be using the AVFoundation's AVPlayer object. You can use an AVPlayer to play local and remote file-based media, such as Code Snippet — 8 In iOS, setting the Ring/Silent switch to silent mode silences any audio being played by the Swift · Programming · Tech · Technology · Data​  This article describes how to use the Wowza GoCoder™ app on Apple iOS devices to publish a live stream to Wowza Streaming Engine™ media server software. You can use Wowza GoCoder for iOS to capture and send encoded live audio and video over 4G, 3G, and Wi-Fi to a Wowza Streaming Engine server, which can then broadcast the content as HD

Please keep in mind since iOS 9: App Transport Security (ATS) configured?

<key>NSAppTransportSecurity</key>
<dict>
   <key>NSExceptionDomains</key>
   <dict>
      <key>yourserver.com</key>
      <dict>
         <!--Include to allow subdomains-->
         <key>NSIncludesSubdomains</key>
         <true/>
         <!--Include to allow HTTP requests-->
         <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
         <true/>
         <!--Include to specify minimum TLS version-->
         <key>NSTemporaryExceptionMinimumTLSVersion</key>
         <string>TLSv1.1</string>
      </dict>
   </dict>
</dict>

Swift 2:

let url = "http://yourserver.com/source.mp3"
    let playerItem = AVPlayerItem(URL:NSURL(string:url)!)
    audio = AVPlayer(playerItem:playerItem)
    audio.rate = 1.0;
    audio.play()

iOS Media APIs (MobiDevDay Detroit, May 2013), I'm working on an app that play audio in Apple Watch; All working fine from inside the notifyOthersOnDeactivation) player.play() } catch { print("Error") } } Remote when using the AVAudioPlayer instead of WKAudioFilePlayer the setup for I stream 'm3u8' files using wowza which worked only with WKAudioFilePlayer. The delegate object for the audio player. protocol AVAudio Player Delegate A protocol that allows a delegate to respond to audio interruptions and audio decoding errors, and to the completion of a sound’s playback.

To check for error in Swift, use:

if let errorDetails = error {
    println("Error creating player: \(errorDetails.localizedDescription)")
} else {
    if player.prepareToPlay() && player.play(){
        println("yes")
    } else {
        println("no")
    }
}

StackOverFlowTagPredictor/tagfreq.in at master · ChokshiUtsav , iOS Media APIsChris Adamson • @invalidnameMobiDevDay • Detroit, UIKit• UIImagePickerController, remote controlevents• AirPlay• HTTP Live AVF audio classes• AVAudioPlayer – plays flat files or audiofrom an NSData• Final Cut), server-side transcoders (Wowza)Thursday, May 2, 13; 29. I've got the following code that I'm trying to get working. My previous AVAudioPlayer code worked, but didn't allow for remote files. I can see the Player.Play(); method firing, but there's no audio coming from the speakers. What do I need to do to get the AvPlayer to play remote audio files?

Contents. About AirPlay 5. Preparing Your Media and Server for , iis-8|5377. fsockopen|1067. login-automation|3. virtocommerce|146. ffmpeg-php|​566 audio-endpoint-device|1 ognl|2053. remote-registry|108 iphone-​standalone-web-app|1148 sql-server-data-services|2 swift-playground|1388 smooth-streaming-player|154 wowza-transcoder|57 avaudioplayer|13665. I'm making my first macOS (not iOS) project in Swift. In my main AppDelegate.swift I instantiate a class called PlaySound and then call startSound() The class called PlaySound.swift plays an mp3. However, I hear no sound unless I put a sleep() soon after I call myPlayer.play() in either class file.

Hero2000, AirPlay can stream Internet-based media when it is playing in ios apps, in the Safari 8 Preparing Your Media and Server for AirPlay For your media to play over SwiftObjective-C Audio content (except for system sounds) and media played via AirPlay attempts to deliver the app audio to a remote sound system while  The video demonstrates integration between native iOS applications and code deployed into Wowza Media Server using Midnight Coders' Comm Library for iOS. The examples reviewed in the video include

How to convert .movpkg to mp4 – IOS Questions, let url = URL(string: "http:myUrl.m3u8") let player = AVPlayer(url: url!) let playerLayer = AVPlayerLayer(player: player) playerLayer.frame  This article describes how to play a video-on-demand (VOD) or live stream from Wowza Streaming Engine™ media server software on Apple iOS devices. Play a VOD .mp4 file This section describes how to play the default [ install-dir ]/content/sample.mp4 video file from an application named vod .

Comments
  • You didn't check whether error contains error or not.
  • how do I check for it?
  • @Raptor AVAudioPlayer not support streaming. For live streaming use AVPlayer
  • it also works if you create 'AVPlayer' directly with url like this: 'avPlayer = AVPlayer(URL: nsUrl)' Only thing you should do is create avPlayer as instance variable if you create avPlayer as local variable it is not working for me.
  • Nice! After I've created AVPlayer as instance variable it started to play!
  • if my url is correct and internet is available, does avPlayer.play() guarantees that my audio will play?. is there any try catch to know if play() was successfull or not ?
  • Also, it does play with a little delay. How can i show some loading indicator in that time?
  • Keep in mind this option involves downloading the mp3 and then playing it. With AVPlayer you can actually stream it.
  • Error creating player: The operation couldn’t be completed. (OSStatus error 2003334207.).
  • the error 2003334207 means AVAudioPlayer requires a local file. Download it from Internet & save it to local before playing it. Hint: use writeToFile
  • @DavidTurton But this code is working well in my current project. So try it once again
  • Could you show me where you are initiating the variable playerURL, maybe I am doing something wrong?
  • Tried this as well and is not working for streaming a file, any other suggestions?
  • @edse test with device
  • I importes Avfoundation and tested on an iPhone but doesnt play audio. I've checkins that the device is not in silent mode as well.