When you request an http address in IOS9, an error is returned. AVAudioPlayer: Why is the code correct but cannot be played? ios9.avaudioplayer

Source: Internet
Author: User

When you request an http address in IOS9, an error is returned. AVAudioPlayer: Why is the code correct but cannot be played? ios9.avaudioplayer

In the new version of Xcode7.1, errors are always reported during HTTP requests. As long as there are http requests, errors are reported. In iOS9, Apple changed the original http protocol to the https protocol, use TLS1.2 SSL to encrypt request data

There are probably two kinds of errors reported.

First: App Transport Security has blocked a cleartext HTTP (http: //) resource load since it is insecure. Temporary exceptions can be configured via your app's Info. plist file.

Second:NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL,-9807)

The solution to these two errors is as follows:Add the following to info. plist:NSAppTransportSecurity. Its type is dictionary. Then, click + to display two options. ThenNSAllowsArbitraryLoadsSelect YES;


Generally, the network of the http request can appear at this time. If the simulator encounters the second situation, it adds s to the http request or removes s (generally, as long as it is the original URL)
//__________________________________________________________________________________________
Once again, I am working on a background player.AVAudioPlayerI checked my code several times and there was no problem, but there was no sound running in the background. In this case, it may be thatSetThe AVAudioPlayer object is set to a global object (probably because if I set it to a local variable, the compiler may retain this object after compiling the code, it takes some time to play a music. You can reation the object before the dealloc program stops running.
)
 
 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.