Skip to content Skip to sidebar Skip to footer

Ios Stream Video From Google Drive Swift

I'm building an iOS app that Stream's video from Google drive the videos link looks like this https://drive.google.com/file/d/0B2Kri7-TaAFJSlJ4UTJuSElGamM/preview The only way to

Solution 1:

I fixed the problem using the method :

let myURLString ="https://drive.google.com/file/d/0B1XhqDeOfqG7UWZSaG1ZbFFhSzQ/preview"iflet myURL =NSURL(string: myURLString) {

        do {
            let myHTMLString =tryString(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)

            let t = myHTMLString

            iflet rangeOfZero = t.rangeOfString("plid", options: NSStringCompareOptions.BackwardsSearch) {

                let suffix =String(t.characters.suffixFrom(rangeOfZero.endIndex))

                //    print(suffix)let input ="\(suffix)"let detector =try!NSDataDetector(types: NSTextCheckingType.Link.rawValue)
                let matches = detector.matchesInString(input, options: [], range: NSRange(location: 0, length: input.utf8.count))

                //  print(matches)for match in matches {

                    let url = (input asNSString).substringWithRange(match.range)

                    linksA.append(url)

                }

                theLink()

            } else {
                print("noooo")
            }
        } catch {
            print("Error : \(error)")
        }
    } else {
        print("Error: \(myURLString) doesn't  URL")
    }

afther that you need to decode the streaming link using this method :

functheLink() {


    /// /[u]00../glet firstElement = linksA.first

    let t = firstElement!.stringByReplacingOccurrencesOfString(",35", withString: "")

    let deUrl = t.characters.split{$0=="|"}.map(String.init)

    let link = deUrl[0]

    // the link needs to be decodedlet i = link.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)


    let p = i!.stringByReplacingOccurrencesOfString("%5Cu", withString: "")


    // you can see how the link should look like here :// http://ddecode.com/hexdecoder/?results=d82d4e564eccc1a6b96ee7c5c1e1c3b2// %252C : ,// 003d : =// 0026 : &let re = p.stringByReplacingOccurrencesOfString("003d", withString: "=")
     let y = re.stringByReplacingOccurrencesOfString("0026", withString: "&")
        let c = y.stringByReplacingOccurrencesOfString("%252C", withString: ",")

    print(c) }

you can see all the code Here

Post a Comment for "Ios Stream Video From Google Drive Swift"