HLS Player gives error and not playing the URL - ios

I tried to play a live streaming url using AVplayer, the url working fine in the web. the server guy told me that in the response content type is application/x-mpegURL and video/MP2T. but when ever I try to play that im getting error messages.
Error Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSUnderlyingError=0x7fe6bcae2170 {Error Domain=CoreMediaErrorDomain Code=-12939 "byte range and no content length - error code is 200" UserInfo={NSDescription=byte range and no content length - error code is 200
ps: the player which i created is working fine with others urls
can you please tell me what i need to do?

Related

AVPlayer won't play audio files from FFMPEG

Before requesting audio data AVPlayer requests byte range 0-1 from FFMPEG.
FFMPEG gives a 200 response, but AVPlayer requires a 206 response.
This results in the request failing and audio can't be played.
Expected behavior:
Play tracks when streaming through ffmpeg
Current behavior: When trying to stream with ffmpeg we get "Operation Stopped"
Sample FFMPEG command:
ffmpeg -i "/path/to/audio/track.mp3" -vn -strict -2 -acodec pcm_u8 -f wav -listen 1 -seekable 1 http://localhost:8090/restream.wav
Player Log:
Error Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation Stopped, NSUnderlyingError=0x600003bcc4b0 {Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"}}
!av_interleaved_write_frame(): Broken pipe
!Connection to tcp://localhost:8090 failed: Connection refused
!Connection to tcp://localhost:8090 failed: Connection refused
!Connection to tcp://localhost:8090 failed: Connection refused
!Error writing trailer of http://localhost:8090/restream.wav: Broken pipe
This error is defined by Apple as:
+"The HTTP server sending the media resource is not configured as expected. This might mean that the server does not support byte range requests."
And summarised nicely in this StackOverflow post:
when AVPlayerItem receive a video URL , it do the following task:
Send a bytes request HTTP Request, and range = 0 -1
If the response code is 206 and return 1 bytes data, It do the 3th task, if not, AVErrorServerIncorrectlyConfigured error occurred.
continue send other HTTP Request, to download segment of All duration. and the response of VideoData code must be 206
In my situation , when send range[0-1] HTTP request, the server side give me a 200 OK response, So error occurred.
Network Log:
GET /file.wav HTTP/1.1
Host: localhost:1234
X-Playback-Session-Id: F72F1139-6F4C-4A22-B334-407672045A86
Range: bytes=0-1
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.18C61 (iPhone; U; CPU OS 14_3 like Mac OS X; en_us)
Accept-Language: en-us
Accept-Encoding: identity
Connection: keep-alive
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Reproduce using this sample app:
This can also be reproduced using standard ffmpeg and adding URL to local or remote ffmpeg URL
Can we solve this by making changes to FFMPEG or AVPlayer?
I asked this question on the ffmpeg email list and it seems it's not possible:
If I understand your request correctly, you are not asking for a
change of a return type (you could probably do that yourself) but for
the implementation of byte range requests. I don't think this is
possible at all with FFmpeg.
Also it's not possible to get AVPlayer to ignore the byte range request:
it is an apple standard that media providers need to support http 1.1
with the range header (check out the iTunes store guidelines for
podcasts for example), so I wouldn't expect it anytime soon
SO Q'n: Is there a way to stop the avplayer sending a range http header field

How can I get this Fairplay HLS setup to work?

I'm running:
mediafilesegmenter movie.mp4 --encrypt-key-file=key.bin --streaming-key-delivery -t 10 --file-base=.`
where key.bin is just aaaaa... (32 a's). Then, in my prog_index.m3u8 file, I set it up as:
#EXT-X-KEY:METHOD=AES-128,URI="http://192.168.1.27/just_key.bin",KEYFORMAT="identity",IV=0x6161616161...
However, when I try to run it, I get:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16040), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c0250200 {Error Domain=NSOSStatusErrorDomain Code=-16040 "(null)"}.
just_key.bin is just 16 a's.
Any ideas what might be the issue? Is there an easy way to get Fairplay going otherwise?
FairPlay uses SAMPLE-AES encryption, not AES-128. Try with:
METHOD=SAMPLE-AES

What the name of the error domain for HTTP error codes?

I have some network code which behaves differently if an error is due to timeout, bad url, url not found etc, etc. which are all covered by NSURLErrorDomain.
However if I get a http error, such as http 406, then that's not in NSURLErrorDomain. The domain is "HTTP Error", but I don't want to use that as a hardcoded string, I want to use whatever its NSWhateverErrorDomain definition is, but after loads of searching I just can't find what that is anywhere.
Undocumented NSURLErrorDomain error codes (-1001, -1003 and -1004) using StoreKit
Reference:
https://developer.apple.com/reference/cfnetwork/cfnetworkerrors

UIWebView loads with error code -1008

Just playing around the UIWebView, I found some very interesting case...
When I hit a site with some xls file (say www.econ.yale.edu/~shiller/data/ie_data.xls) and now visit any other site and go back to the previous visited xls file. this file loads with an error and
webView(_ webView: UIWebView,didFailLoadWithError error: NSError?)
gets called with following error "resource unavailable", here is the destription
Error Domain=NSURLErrorDomain Code=-1008 "resource unavailable" UserInfo={NSErrorFailingURLKey=x-apple-ql-id://02C2F712-77CE-4015-8237-31BB4B203221/x-apple-ql-magic/Sheet0.html, NSLocalizedDescription=resource unavailable, NSErrorFailingURLStringKey=x-apple-ql-id://02C2F712-77CE-4015-8237-31BB4B203221/x-apple-ql-magic/Sheet0.html}
So guys I really curious to know what is this error all about and what -1008 error code says.
Note: This happens only in case of xls file

Strange Behaviour while loading URL in Webview in IOS

It looks simple, but don't know what goes wrong. I am trying to load a basic URL in WebView, as shown below
WebsiteWebView.delegate=self;
NSURL* url = [NSURL URLWithString:#"http://firstclasspizzaoc.com/"];
[WebsiteWebView loadRequest:[NSURLRequest requestWithURL:url]];
while loading i am getting below error everytime..
Error : Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0xe036d20 {NSErrorFailingURLKey=http://firstclasspizzaoc.com/, NSErrorFailingURLStringKey=http://firstclasspizzaoc.com/}
2014-01-07 15:18:46.142 FirstClassPizza[1583:
Error : Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0xe0ef310 {NSErrorFailingURLStringKey=XXXXXXXX, NSErrorFailingURLKey=XXXXXXXX, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0xcbe9130 "A server with the specified hostname could not be found."}
At Browser it is loading perfectly..
Please suggest what went wrong in my code..
Any Valuable suggestions will be appreciated...
Thanks
It is due to Your Web URL http://firstclasspizzaoc.com/ can you use your url with
http://www.firstclasspizzaoc.com/
You can find your answer here :
How do I fix NSURLErrorDomain error -999 in iPhone 3.0 OS
This thread contained this description for this error: "This error may occur if an another request is made before the previous request of WebView is completed..."
I worked around this by ignoring this error and letting the webview continue to load.
if ([error code] != NSURLErrorCancelled) {
//show error alert, etc.
}

Resources