Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

If want to use youtube user ID All the same people in flutter Of uploading files, it can be done or not

$
0
0

To upload files to youtube How to do it, I have been studying for about a while.

class YoutubeService {  static Future<YouTubeApi> getYoutubeApi() async {    final GoogleSignIn googleSignIn = GoogleSignIn(      scopes: <String>[        YouTubeApi.youtubeReadonlyScope,        YouTubeApi.youtubeUploadScope      ],    );    await googleSignIn.signIn();    // final GoogleSignInAccount? googleSignInAccount = await googleSignIn.signIn();    var httpClient = await googleSignIn.authenticatedClient();    if (httpClient == null) {      print("You didn't allow to proceed with YouTube access");    }    return YouTubeApi(httpClient!);  }  static Future<VideoListResponse> listYoutubePlaylists() async {    var youTubeApi = await getYoutubeApi();    var data = await youTubeApi.videos.list(      ['snippet'],      chart: "mostPopular",    );    return data;  }  static File? f;  static Future<Video>? videoInsertRequest;  static Future<Video> upload() async {    var youTubeApi = await getYoutubeApi();    FilePickerResult? result = await FilePicker.platform.pickFiles();    if (result != null) {      f = File(result.files.single.path.toString());    }    //File f = File('assets/sample-mp4-file-small.mp4');    Stream<List<int>> stream = f!.openRead();    Media m = Media(stream, (await f!.length()));    Video video = Video(      snippet: VideoSnippet(        title: 'Test Video',        description: 'Test Upload for My App',        categoryId: '22',      ),    );    videoInsertRequest = youTubeApi.videos.insert(      video,      ['snippet', 'status'],      uploadMedia: m,    );    videoInsertRequest!.whenComplete(      () => print("Succeed")    );    return videoInsertRequest!;  }}

if function getYoutubeApi().How do I enter the desired code?

Another question of this function is if login app with google, is this function call if not set? the desired ID

I call upload() function but not upload to youtube. which has been waiting for a very long time because there is no print Succeed value. I am going to develop a progress bar after print Succeed succeeds.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>