您这样做是正确的,但是使用旧的方法,将您的代码更新为下面提到的内容,也请查看最新的youtube_explode_dart
个包的文档以更好地理解.
Future<String> getDownloadUrl(String videoId) async {
var youtube = YoutubeExplode();
var video = await youtube.videos.get(videoId);
// Get the stream manifest for the video
var streamManifest = await youtube.videos.streamsClient.getManifest(videoId);
// Get the audio-only streams from the manifest
var audioOnlyStreams = streamManifest.audioOnly;
// Get the highest quality audio-only stream
var audioStream = audioOnlyStreams.withHighestBitrate();
// Return the URL of the audio stream
return audioStream.url.toString();
}