1

I am able to stream music file of google drive using downloadUrl method of V2 API, but is there is any alternate method in V3 API to fetch 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
        }

    }];
}
IOS Coder
  • 11
  • 3
  • Please consult the documentation and come back if you have any problems. – Linda Lawton - DaImTo Sep 26 '16 at 06:56
  • @DalmTo Consulted documentation, able to fetch webcontentLink and all, but not able to stream. Any idea how to generate streaming link? – IOS Coder Sep 26 '16 at 07:15
  • Can you show some code so that we can help you. – Linda Lawton - DaImTo Sep 26 '16 at 07:21
  • @DalmTo Question Updated with code, please check and suggest alternate method for streaming in V3 API – IOS Coder Sep 26 '16 at 07:59
  • I cant sorry I am not an IOS programmer that's why its best when asking a question to always tag with the language and add your code from the start. Its tagged now hang in there someone with the power of IOS should respond. – Linda Lawton - DaImTo Sep 26 '16 at 08:04
  • Have you checked out [this answer](http://stackoverflow.com/questions/18893183/google-drive-sdk-audio-video-streaming-in-ios-application) by @Nitesh? It suggests to pass the access_token to the `AVPlayer` object to play music – adjuremods Sep 27 '16 at 09:41
  • @adjuremods The above answer works for V2 API. In V3 API downloadUrl method is removed. I tried with webContentLink as an replacement for downloadUrl but it doesn't work – IOS Coder Sep 29 '16 at 04:15

0 Answers0