Giter Site home page Giter Site logo

Comments (7)

tarekbazine avatar tarekbazine commented on July 23, 2024 1

All fine, I figured out the issue, I will be preparing a PR soon.

from just_audio.

ryanheise avatar ryanheise commented on July 23, 2024 1

PR is now merged, thank you!

from just_audio.

ryanheise avatar ryanheise commented on July 23, 2024

Hi @terryBaz , yes I welcome pull requests. This is definitely an important feature.

I think it would make sense for setUrl to throw an exception and so a stream of errors on this occasion wouldn't be needed. This can be achieved on the platform side by sending an error through the platform channel. For example, on Android:

prepareResult.error("error message", null, null);

And on iOS with this code:

_connectionResult([FlutterError errorWithCode:@"error message"
                                 message:nil
                                 details:nil]);

from just_audio.

tarekbazine avatar tarekbazine commented on July 23, 2024

cool, that is what I started doing, but I am running into an issue with ExoPlayer State when I try to call prepareResult.error(...), the app is being killed (I am running the example project with a wrong url) plz let me know if u have some hints

  • the added code to AudioPlayer.java
    @Override
    public void onPlayerError(ExoPlaybackException error) {
        switch (error.type) {
            case ExoPlaybackException.TYPE_SOURCE:
                Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
                this.setError(String.valueOf(error.type), error.getUnexpectedException().getMessage());
                break;

            case ExoPlaybackException.TYPE_RENDERER:
                Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
                break;

            case ExoPlaybackException.TYPE_UNEXPECTED:
                Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
                break;

            default:
                Log.e(TAG, "default: " + error.getUnexpectedException().getMessage());

        }
    }
....
    private void setError(String errorCode, String errorMsg) {
        this.dispose();
        if (prepareResult != null) {
            prepareResult.error(errorCode, errorMsg, null);
            prepareResult = null;
        }
    }
....
    public void dispose() {
        player.release();
        transition(PlaybackState.none);
    }
  • the log from LogCat
02-01 12:09:11.942 20841-20841/com.ryanheise.just_audio_example E/AudioPlayer: TYPE_SOURCE: Response code: 404
02-01 12:09:11.946 20841-20841/com.ryanheise.just_audio_example E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ryanheise.just_audio_example, PID: 20841
    java.lang.IllegalStateException
        at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:81)
        at com.google.android.exoplayer2.ExoPlaybackException.getUnexpectedException(ExoPlaybackException.java:220)
        at com.ryanheise.just_audio.AudioPlayer.onPlayerError(AudioPlayer.java:135)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.lambda$run$2$ExoPlayerImpl$PlaybackInfoUpdate(ExoPlayerImpl.java:812)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$PlaybackInfoUpdate$fI_Ao37C4zouOtNaX7xHdRfgmVc.invokeListener(Unknown Source:2)
        at com.google.android.exoplayer2.BasePlayer$ListenerHolder.invoke(BasePlayer.java:182)
        at com.google.android.exoplayer2.ExoPlayerImpl.invokeAll(ExoPlayerImpl.java:845)
        at com.google.android.exoplayer2.ExoPlayerImpl.access$000(ExoPlayerImpl.java:43)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.run(ExoPlayerImpl.java:812)
        at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners(ExoPlayerImpl.java:736)
        at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:710)
        at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:652)
        at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent(ExoPlayerImpl.java:595)
        at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage(ExoPlayerImpl.java:127)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7555)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)

from just_audio.

ryanheise avatar ryanheise commented on July 23, 2024

Hi @terryBaz I'm curious about the code in your comment which is marked as "Resolved". Is that the code you were including in your PR?

from just_audio.

tarekbazine avatar tarekbazine commented on July 23, 2024

I already find a solution for this and I am using it, but I still did not prepare a PR yet, sorry for that, did not have time for it, but I will try to prepare one Asap (hopefully in the next 2 days)

from just_audio.

github-actions avatar github-actions commented on July 23, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.

from just_audio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.