Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't play any song on MacOS #23

Closed
nank1ro opened this issue Feb 7, 2022 · 18 comments
Closed

Can't play any song on MacOS #23

nank1ro opened this issue Feb 7, 2022 · 18 comments
Labels
bug Something isn't working

Comments

@nank1ro
Copy link

nank1ro commented Feb 7, 2022

Describe the bug
Cannot play any song on MacOS

To Reproduce
Steps to reproduce the behavior:

  1. Open app
  2. Click on any song
  3. It never starts

Expected behavior
The song begins

Installation Source/Method

  • Compiled from source with flutter run -d macos

Desktop (please complete the following information):

  • OS: MacOS Monterey (Intel)
  • Version: 12.1

Additional context
Error logs:

flutter: [Player._playTrack()] (-1002) unsupported URL
flutter: #0      AudioPlayer._load (package:just_audio/just_audio.dart:778:9)
<asynchronous suspension>
#1      AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1346:28)
<asynchronous suspension>

flutter: [Player._playTrack()] (-1002) unsupported URL
flutter: #0      AudioPlayer._load (package:just_audio/just_audio.dart:778:9)
<asynchronous suspension>
#1      AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1346:28)
<asynchronous suspension>
#2      AudioPlayer.play (package:just_audio/just_audio.dart:852:28)
<asynchronous suspension>
#3      _PlayerState.build.<anonymous closure>.<anonymous closure> (package:spotube/components/Player/Player.dart:266:25)
<asynchronous suspension>
#4      _PlayerControlsState._playOrPause (package:spotube/components/Player/PlayerControls.dart:54:51)
<asynchronous suspension>

flutter: [PlayerControls.onPlay()] MissingPluginException(No implementation found for method play on channel com.ryanheise.just_audio.methods.0da27819-4fea-44be-9760-3ab4d0a51324)
flutter: #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
<asynchronous suspension>
#1      MethodChannelAudioPlayer.play (package:just_audio_platform_interface/method_channel_just_audio.dart:56:34)
<asynchronous suspension>
#2      AudioPlayer._sendPlayRequest (package:just_audio/just_audio.dart:890:7)
<asynchronous suspension>
@nank1ro nank1ro added the bug Something isn't working label Feb 7, 2022
@nank1ro nank1ro changed the title Can't play audio on MacOS Can't play song on MacOS Feb 7, 2022
@nank1ro nank1ro changed the title Can't play song on MacOS Can't play any song on MacOS Feb 7, 2022
@KRTirtho
Copy link
Owner

KRTirtho commented Feb 7, 2022

It says the just_audio_macos native plugin is missing
I guess the flutter pub dependencies weren't resolved correctly. Try running:

$ flutter clean
$ flutter pub get
$ flutter run -d macos

@nank1ro
Copy link
Author

nank1ro commented Feb 7, 2022

Tried, same error:

flutter: [Player._playTrack()] (-1002) unsupported URL
flutter: #0      AudioPlayer._load (package:just_audio/just_audio.dart:778:9)
<asynchronous suspension>
#1      AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1346:28)
<asynchronous suspension>

@KRTirtho
Copy link
Owner

KRTirtho commented Feb 7, 2022

That's a really weird bug. Can you debug following line in your IDE & check the currentTrack.uri if it's a valid URL string or not visually?

AudioSource.uri(Uri.parse(currentTrack.uri!)),

@nank1ro
Copy link
Author

nank1ro commented Feb 7, 2022

The uri is present: spotify:track:1tNJrcVe6gwLEiZCtprs1u , but doesn't seem a valid URL

@nank1ro
Copy link
Author

nank1ro commented Feb 7, 2022

Debug:
Screenshot 2022-02-07 at 18 36 48

@KRTirtho
Copy link
Owner

KRTirtho commented Feb 7, 2022

Thanks. And that's seems to be ok since the currentTrack isn't yet converted into a YoutubeTrack. Can you debug this line & see if the ytTrack.uri contains a valid URL string?

.setAudioSource(AudioSource.uri(Uri.parse(ytTrack.uri!)))

@nank1ro
Copy link
Author

nank1ro commented Feb 8, 2022

The app crashes on this method (line 142):

await player
              .setAudioSource(
            AudioSource.uri(Uri.parse(currentTrack.uri!)),
            preload: true,
          )

I've added a catchError and the error is PlayerException ((-1002) unsupported URL)

It never reaches the line 156

@KRTirtho
Copy link
Owner

KRTirtho commented Feb 8, 2022

I've made some changes there. Try pulling the new modifications & see if works now

@nank1ro
Copy link
Author

nank1ro commented Feb 8, 2022

Now I'm getting a crash here

.setAudioSource(AudioSource.uri(Uri.parse(ytTrack.uri!)))

with error:

[Player._playTrack()] (-11828) Cannot Open

@KRTirtho
Copy link
Owner

KRTirtho commented Feb 9, 2022

How does the ytTrack.uri look? Is it a valid URL string? I guess it's the AVFoundation framework of Mac OS isn't recognizing the URL as a valid URL because there's no mimetype in the headers

If this is the case then ytTrack.uri!+".mp3" should fix issue

@nank1ro
Copy link
Author

nank1ro commented Feb 10, 2022

I've tried to add .mp3 but th error is the same.
I also tried to open the URL in the browser but I get this error: Access to rr2---sn-hpa7zned.googlevideo.com was denied. You don't have authorisation to view this page.

@KRTirtho
Copy link
Owner

Can you provide me the URL you're getting in ytTrack.uri

@nank1ro
Copy link
Author

nank1ro commented Feb 10, 2022

https://rr1---sn-hpa7kn7d.googlevideo.com/videoplayback?expire=1644528990&ei=_jAFYreKA4vH7gPgrK34DQ&ip=185.2.145.1&id=o-AICUwqQ1-FhTZuzxUAf2_o9fTpJPTwRAYU-ejwPkojYD&itag=251&source=youtube&requiressl=yes&mh=L_&mm=31%2C29&mn=sn-hpa7kn7d%2Csn-hpa7zned&ms=au%2Crdu&mv=m&mvi=1&pl=23&initcwndbps=1230000&vprv=1&mime=audio%2Fwebm&ns=hSvkWc72lZa6EOGP9pk_TwgG&gir=yes&clen=3003106&dur=169.181&lmt=1633027712541531&mt=1644506999&fvip=1&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=6432434&n=Pa3YXadXYq_YCUs&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAL1hqVIVGu-IbTNWRZsW6j7CS8Xu9xyATSR8kHDu706GAiEAlJHbvD3OQ7uZaF_3DJz11F4g5PwGyoIXGYB3gWTtUts%3D&sig=AOq0QJ8wRQIgWpC7pdIdU19nm29yS-fMoSENeFPLLhtMg-sH_9BM2ocCIQC6wBSJvA8EJcwNQAVHiJ3ZHVF9KWIzzJSUQwYkG98vxA%3D%3D

@nank1ro
Copy link
Author

nank1ro commented Feb 10, 2022

If I go with the browser without the .mp3 added I can listen to the song.

@KRTirtho
Copy link
Owner

I found out the actual issue is Mac OS & iOS CoreAudio not supporting WebMedia codec aka webm, weba & webp in previous versions. Spotube was pulling the audio/webm audio file to get best possible bitrate but it doesn't work on all Macs currently

I've updated the code to pull only audio/mp4 audio in Macs which comes with a downside of having 140 kbps bitrate instead 251 kbps of the audio/webm

Please, pull from git & see if audio works now or not

@nank1ro
Copy link
Author

nank1ro commented Feb 10, 2022

Now it works! Amazing work 💪🥳
Feel free to close this issue cause has been fixed

@KRTirtho
Copy link
Owner

Glad it worked

@KRTirtho KRTirtho added this to Needs triage in Sayonara Bugs via automation Feb 10, 2022
@KRTirtho KRTirtho moved this from Needs triage to Closed in Sayonara Bugs Feb 10, 2022
@PranavBhattarai
Copy link

Taiko2k/Tauon#717 (comment)
@KRTirtho
Am I curious:

  1. Are we downloading the songs in " DASH MP4's" codec and renaming the file to .mp3 because of this issue?
  2. If so, then why are doing it the wrong way to 'get the things' done?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

3 participants