fluttergoogle-drive-apiflutter-webexoplayerflutter-video-player

How to play video from Google Drive in Better Player - Flutter?


In my app, I already integrated with google login and I successfully accessed my google drive folder and video files(mp4). But better player can play public video by modified url like this https://drive.google.com/uc?id=my_video_file_id. I want to develop an app like Nplayer or Kudoplayer.

Can anyone guide me some scenario of Nplayer or Kudoplayer? and guide me how to play private drive's video using better player. Thanks.


Solution

  • Finally I got solution after research for a long time :-)

    Summary answer for this question


    For guys who face issue like me, please follow these step

    Next step that I stuck is

    Like this

    BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource(
      BetterPlayerDataSourceType.network,
        "https://www.googleapis.com/drive/v3/files/$fileId?alt=media",
        videoExtension: ".mp4",
        headers: getDataFromCache(CacheManagerKey.authHeader),
     );
    

    authHeader can get when you call signWithGoogle function, I save it and retrieve later. In signWithGoogle function, you can get authHeader using this

    Map<String, String> authHeader = await googleSignIn.currentUser!.authHeaders;
    

    Bonus - Queries For You.