youtube_explode_dart 包 flutter 中的未定义名称 streamManifest

Undefined name streamManifest in youtube_explode_dart package flutter

我在 flutter 中处理 youtube_explode_dart 包的文档时遇到问题。我正在尝试使用这个包和 firebase 存储构建一个音乐流媒体应用程序,但它们在文档代码中似乎有一些错误(下面给出的代码)

// Get highest quality muxed stream
var streamInfo = streamManifest.muxed.withHigestVideoQuality();

// ...or highest bitrate audio-only stream
var streamInfo = streamManifest.audioOnly.withHigestBitrate()

// ...or highest quality MP4 video-only stream
var streamInfo.videoOnly.where((e) => e.container == Container)

当我尝试使用此代码时,它说 streamManifest is not defined name 这是正确的,因为它未定义!。我试图通过声明 streamManifest 来修复它,但没有用。任何人都可以检查这个或者如果他们已经使用过这个包那么请帮助。一些好的帮助将不胜感激。

Link 到文档 - https://pub.dev/packages/youtube_explode_dart

如软件包文档中所述,您可以在 GitHub

上找到一个工作示例
 var yt = YoutubeExplode();
 var id = VideoId("https://youtu.be/cqY_tJfhKLw");//for example
 var video = await yt.videos.get(id);
 // Get the streams manifest and the audio track.
 var manifest = await yt.videos.streamsClient.getManifest(id);
 var audio = manifest.audioOnly.last;

              

这就是我使用 youtube_explore_dart 库的经验。 使用终端安装库的最新更新

flutter pub add youtube_explode_dart

然后,

var _yt = YoutubeExplode();
var manifest_ = await _yt.videos.streamsClient.get(_youtubeVideoId) // with _youtubeVideoId is the id of youtube video example LoSm6VkplJc
var streamInfo = manifest.audioOnly
    .withHighestBitrate()

这是为了获取最高音质的音频流。然后您可以使用 Its infos 和 streamsClient 下载该视频流,然后您可以将其流式传输到系统中的本地文件。

if (streamInfo != null) {
    var stream = _yt.videos.streamsClient.get(streamInfo);
    _fileName = file.path; // this is path of Directory instance
    var fileStream = file.openWrite();

      // Pipe all the content of the stream into the file.
      try {
        await stream.pipe(fileStream).then((value) {
          return value;
        }).catchError((err) => error = err);
      } catch(err){
        error = err.toString();
      }

      // Close the file.
      await fileStream.flush();
      await fileStream.close();
}