-5

I put the m3u8 in GCDWebServer to play. When I use Wi-Fi, it is no problem. But using 4G, appears this problem.

enter image description here

enter image description here

Barbora
  • 921
  • 1
  • 6
  • 11

2 Answers2

0

You are force unwrapping m3u8 in your code. If that's ever nil, you're going to have a problem. You're saying that it will never be nil when you force unwrap using that !.

You can use the if let approach, or you can test for nil too.

// Are you sure dataServer isn't nil too here?
if let serverAddress = dataServer!.serverURL.URLByAppendingPathComponent(self.m3u8) {
    //Should be safe
}

Or

if m3u8 == nil {
    print("m3u8 is nil")
    return
}
0

I have already solved the problem.When I use 4 g, access to the dataServer!ServerURL is nil.My solution is to give it a local IP

 if davServer?.serverURL == nil {
                serverAddress = NSURL.init(string: "http://localhost/playts.m3u8")!
            }else{
               serverAddress = (davServer?.serverURL.URLByAppendingPathComponent(self.m3u8!))!
            }