-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSURLConnection Error Code 1002 #18
Comments
Sorry for late response. Is this issue still a case? FYI, the link is broken. |
Yeah, I sanitized the link, not sure if it was necessary, but yeah, it won’t work. And I haven’t tried it since. I assume it’s still a problem but I can check. |
From your code I can see that you initialize ‘playerItem’ with just a url. And your url doesn’t contain a file extension. Thus, CachingPlayerItem can’t refer the type of the file. Try using another initializer that takes custom file extension along with url. |
I tried that too, and it didn't work. The URL actually does contain a file extension. The problem is the token comes after the URL as an option in the URL string: Here's the first part of the URL: And here are the query components, including the token: The file can't be accessed without the query components because of security rules. |
Yeah, missed that part. If you provide a valid url I can take a look. |
Works fine for me. Here's the code: let url = URL(string: "https://firebasestorage.googleapis.com/v0/b/foodapp-600e4.appspot.com/o/projects%2F2eoifj02gpwodsjg02ssd%2F02C3E19E-B3F5-4325-80D0-CF89F6B486DD.m4a?alt=media&token=b35bfd0a-663b-4584-9cf2-1e7d69fddcd3")!
let playerItem = CachingPlayerItem(url: url)
player = AVPlayer(playerItem: playerItem)
player.automaticallyWaitsToMinimizeStalling = false
player.play() |
Also I've noticed that the file you provided starts playing only when fully downloaded as opposed to, say, https://github.com/robovm/apple-ios-samples/blob/master/avTouch/sample.m4a?raw=true. You might want to take a look at this issue #12. |
I have the same issue when I try to access currentItem.asset right after play started. Is there other way to do that? |
Are you experiencing the same crash when you try to access an asset? If it's just about getting the duration, then take into account that a file should contain certain metadata in order for you to know the duration before the file is fully loaded. Please take a look at #12. |
Yes, I am. The issue is raised when I access asset immediately after start playing. I avoid the issue by checking if currentItem.status == .readyToPlay then I access the asset. |
did anybody manage to solve 1002 error code ? I'm facing the same issue with the url: https://www.sample-videos.com/audio/mp3/crowd-cheering.mp3 |
I am also having this issue unfortunately! It only seems to happen like 15% of the time and not always the same song. Sound works initially but it stops after the 1002 error happens for the first time. I'm going to keep debugging! |
Hi, I am trying to use this with Firebase Storage. I have audio files stored there with URLs that look like this:
https://firebasestorage.googleapis.com/v0/b/audiomeshchat.appspot.com/o/projects%2H0wy4AwppfUSozaxeAMNGbA8Vyum1%2F0B7D5C4F-F65B-495C-A06E-35C236B5B5FC.m4a?alt=media&token=a5f7fcb3-0541-453e-8a47-55563518bbef6
My app works great with the following code:
But when I simply switch it to use CachingPlayerItem, the audio won't play and I get NSURLConnection error code 1002.
What's weird is the file is successfully downloaded and cached. But the audio player won't play. Is it possible to make this work with Firebase storage URLs? My security rules are set up such that without the token, files can't be accessed.
The text was updated successfully, but these errors were encountered: