mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-14 08:25:16 +00:00
using audio/mp4 for MacOS & iOS Platform for compatibilty
This commit is contained in:
parent
76fb153ff6
commit
88b201b24b
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
||||
|
||||
@ -21,7 +23,16 @@ Future<Track> toYoutubeTrack(YoutubeExplode youtube, Track track) async {
|
||||
|
||||
var trackManifest = await youtube.videos.streams.getManifest(ytVideo.id);
|
||||
|
||||
track.uri = trackManifest.audioOnly.withHighestBitrate().url.toString();
|
||||
// Since Mac OS's & IOS's CodeAudio doesn't support WebMedia
|
||||
// ('audio/webm', 'video/webm' & 'image/webp') thus using 'audio/mpeg'
|
||||
// codec/mimetype for those Platforms
|
||||
track.uri = (Platform.isMacOS || Platform.isIOS
|
||||
? trackManifest.audioOnly
|
||||
.where((info) => info.codec.mimeType == "audio/mp4")
|
||||
.withHighestBitrate()
|
||||
: trackManifest.audioOnly.withHighestBitrate())
|
||||
.url
|
||||
.toString();
|
||||
track.href = ytVideo.url;
|
||||
return track;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
|
@ -49,6 +49,7 @@ dependencies:
|
||||
just_audio_libwinmedia: ^0.0.4
|
||||
path: ^1.8.0
|
||||
path_provider: ^2.0.8
|
||||
collection: ^1.15.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user