bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2k stars 844 forks source link

Player fails if certificate error #639

Open Z6P0 opened 4 years ago

Z6P0 commented 4 years ago

I try to play MP3 files from a server (not mine) with an invalid certificate. It plays in other players and browsers, but it fails with audioplayers package.

Check for example the URL "https://streaming-canal-u.fmsh.fr/vod/media/canalu/videos/iap/r.sultats.de.la.mission.juno_55111/philippezarka.mp3".

wget says: ERROR: cannot verify streaming-canal-u.fmsh.fr's certificate, issued by 'CN=TERENA SSL CA 3,O=TERENA,L=Amsterdam,ST=Noord-Holland,C=NL': Unable to locally verify the issuer's authority.

I tried to bypass the certificate check with HttpOverrides as documented here but it didn't work: https://github.com/flutter/flutter/issues/19588#issuecomment-406779390

It fails with this uninformative error: onPlayerError MediaPlayer error with what:MEDIA_ERROR_UNKNOWN {what:1} extra:MEDIA_ERROR_SYSTEM

Platform: Android 10

sathishmscict commented 4 years ago

Same issue here : W/MediaHTTPConnection(18260): request failed with error => 0 D/MediaHTTPConnection(18260): setReadTimeout with 30000ms I/System.out(18260): (HTTPLog)-Static: isSBSettingEnabled false I/System.out(18260): (HTTPLog)-Static: isSBSettingEnabled false

Gustl22 commented 2 years ago

Did you add usesCleartextTraffic in Android Manifest?

Z6P0 commented 2 years ago

Did you add usesCleartextTraffic in Android Manifest?

Yes but it's useless as it's a HTTPS link here.

Gustl22 commented 2 years ago

I also get an error, but another one, so usesCleartextTraffic should work fine, also to accept invalid ssl connections:

java.io.IOException: Prepare failed.: status=0x1
    at android.media.MediaPlayer._prepare(Native Method)
    at android.media.MediaPlayer.prepare(MediaPlayer.java:1276)
    at xyz.luan.audioplayers.player.MediaPlayerPlayer.prepare(MediaPlayerPlayer.kt:89)
    at xyz.luan.audioplayers.player.WrappedPlayer.configAndPrepare(WrappedPlayer.kt:310)
    at xyz.luan.audioplayers.player.WrappedPlayer.setSource(WrappedPlayer.kt:31)
    at xyz.luan.audioplayers.AudioplayersPlugin.handler(AudioplayersPlugin.kt:89)
    at xyz.luan.audioplayers.AudioplayersPlugin.access$handler(AudioplayersPlugin.kt:23)
    at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:39)
    at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:39)
    at xyz.luan.audioplayers.AudioplayersPlugin$safeCall$1.invokeSuspend(AudioplayersPlugin.kt:60)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Gustl22 commented 2 years ago

But https://streaming-canal-u.fmsh.fr without valid certificate is forwarded to https://vod.canal-u.tv/ with a valid certificate. I don't think my error comes from the certificate rather than the forwarding. If I play it from the forwarded source, it works fine. Do you have a file url, which is not forwarded to another server and uses an invalid certificate?

Z6P0 commented 2 years ago

Do you have a file url, which is not forwarded to another server and uses an invalid certificate?

Here is an example: https://cdn-preview-e.deezer.com/stream/c-e6b5f2295c3af5280cc00b3bf842ff57-9.mp3

Gustl22 commented 2 years ago

Confirmed, but still getting:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Unexpected error!, Prepare failed.: status=0x1, java.io.IOException: Prepare failed.: status=0x1
E/flutter ( 4651):  at android.media.MediaPlayer._prepare(Native Method)
E/flutter ( 4651):  at android.media.MediaPlayer.prepare(MediaPlayer.java:1276)
E/flutter ( 4651):  at xyz.luan.audioplayers.player.MediaPlayerPlayer.prepare(MediaPlayerPlayer.kt:89)
E/flutter ( 4651):  at xyz.luan.audioplayers.player.WrappedPlayer.configAndPrepare(WrappedPlayer.kt:310)
E/flutter ( 4651):  at xyz.luan.audioplayers.player.WrappedPlayer.setSource(WrappedPlayer.kt:31)
E/flutter ( 4651):  at xyz.luan.audioplayers.AudioplayersPlugin.handler(AudioplayersPlugin.kt:91)
E/flutter ( 4651):  at xyz.luan.audioplayers.AudioplayersPlugin.access$handler(AudioplayersPlugin.kt:25)
E/flutter ( 4651):  at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:41)
E/flutter ( 4651):  at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:41)
E/flutter ( 4651):  at xyz.luan.audioplayers.AudioplayersPlugin$safeCall$1.invokeSuspend(AudioplayersPlugin.kt:62)
E/flutter ( 4651):  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/flutter ( 4651):  at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/flutter ( 4651):  at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
E/flutter ( 4651):  at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
E/flutter ( 4651):  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
E/flutter ( 4651):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
E/flutter ( 4651):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
E/flutter ( 4651):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
E/flutter ( 4651): , null)
E/flutter ( 4651): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter ( 4651): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
E/flutter ( 4651): <asynchronous suspension>
E/flutter ( 4651): #2      _SourcesTabState.setSource (package:audioplayers_example/tabs/sources.dart:39:7)
E/flutter ( 4651): <asynchronous suspension>
Gustl22 commented 1 year ago

Note: this is not #1260 as this is using proper mp3 codec and is playable as asset source.