通过V3 API流式传输Google云端音乐

时间:2016-09-26 04:25:48

标签: ios google-drive-api google-drive-realtime-api

我可以使用V2 API的downloadUrl方法流式传输google驱动器的音乐文件,但V3 API中是否还有其他方法可以获取downloadUrl?

GTLQueryDrive *query =
    [GTLQueryDrive queryForFilesList];
    query.q = @"mimeType='audio/mpeg' or mimeType='audio/x-m4a'";
    query.fields = @"files(id,name,parents,webContentLink)";
    [self.service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {

        if (error == nil) {

            GTLDriveFileList *fileList = (GTLDriveFileList *)object;

             NSString *urlString = [NSString stringWithFormat:@"%@?alt=media", NSURLfileList.files[0].webContentLink];

    AVPlayer(initWithUrl:songUrl).play() // abstract method for stream, ignore syntax

        } else {
            //error
        }

    }];
}

0 个答案:

没有答案