Giter Club home page Giter Club logo

Comments (20)

foolip avatar foolip commented on August 18, 2024

Do you mean to trigger the default actions for when a media session is interrupted and then resumes again?

from mediasession.

richtr avatar richtr commented on August 18, 2024

Firstly play/pause behavior is enforced against current playing media in the current model. When you are interrupted you lose media focus and your media resources must stop – i.e. pause() media elements and suspend() AudioContext objects (pending Web Audio support in the spec).

Secondly, not exposing play/pause means a web developer cannot ignore/override that interruption request. If your media is interrupted you cannot e.g. preventDefault() on receiving a MediaSession 'pause' event or immediately re-invoke play(). That's going to mess up whatever was trying to get media focus and would indefinitely prevent other web pages from playing their media.

from mediasession.

foolip avatar foolip commented on August 18, 2024

Whether or not pausing is enforced seems orthogonal to whether or not play/pause are exposed. IIUC, Anne is simply asking why it's not possible to play and pause all the things controlled by a session while it is active. You can implement it with scripts of course, but if there's some plausible reason to want the convenience methods exposed, it seems harmless to do so.

from mediasession.

richtr avatar richtr commented on August 18, 2024

Ah, right. Thanks for the clarification.

Adding play() and pause() methods to MediaSession objects sounds doable as a convenience feature.

from mediasession.

mounirlamouri avatar mounirlamouri commented on August 18, 2024

I would prefer to leave that for later. We might want to focus on the basics before introducing helper methods. Also, if we were to go this route, exposing the elements that are part of the MediaSession might be a better idea, doesn't it?

from mediasession.

annevk avatar annevk commented on August 18, 2024

I'm not sure I understand. When play/pause are pressed on the keyboard/lockscreen, how does the application know whether to play/pause non-connected bits, such as an animation? (Or adjust network policies, etc.)

from mediasession.

mounirlamouri avatar mounirlamouri commented on August 18, 2024

As far as the MediaSession is concerned, I think play/pause button should resume/interrupt the session.

from mediasession.

foolip avatar foolip commented on August 18, 2024

When play/pause are pressed on the keyboard/lockscreen, how does the application know whether to play/pause non-connected bits, such as an animation?

If the animations are sync'd with a media element, using currentTime and listening to pause events might suffice. If it's Web Audio, it really depends on what that integration looks like, there is a definite risk that there won't be any events to hang this on to.

If we fix #78 we'd have event for the cause of the pausing and playing, might that be sufficient or is the case you have in mind more intricate?

from mediasession.

annevk avatar annevk commented on August 18, 2024

I think that's sufficient, but ideally @ehsan or @sicking confirms.

from mediasession.

annevk avatar annevk commented on August 18, 2024

The other case for exposing play/pause is for letting a page integrate with Flash. They could use these events to drive some code in Flash.

from mediasession.

foolip avatar foolip commented on August 18, 2024

But if play/pause simply act on the participating media elements and audio contexts and there are none in the case of Flash, how does that work? Perhaps I'm misunderstanding the proposed behavior of web-exposed play/pause methods.

from mediasession.

annevk avatar annevk commented on August 18, 2024

Wait, not methods, events on MediaRemoteControls.

from mediasession.

ehsan avatar ehsan commented on August 18, 2024

I think that's sufficient, but ideally @ehsan or @sicking confirms.

No that's not sufficient. We need the play and pause events on MediaRemoteControls for Flash, which is a crucial use case of this API for Mozilla. Also, the solution in #69 (comment) for media elements seems pretty backwards, we need to let authors to more complicated things, such as receive a play event, and schedule an audio node to be started and faded in after a timeout, for example.

from mediasession.

foolip avatar foolip commented on August 18, 2024

OK, yes, fixing #78 would not be sufficient, because interruptions are not the only cause of play/pause, notable using the play/pause button should also do that :)

Presumably, then, we should fire non-cancelable play/pause events whenever we're going to play/pause all of the participating media elements, and audio contexts if we can figure that out.

from mediasession.

ehsan avatar ehsan commented on August 18, 2024

OK, yes, fixing #78 would not be sufficient, because interruptions are not the only cause of play/pause, notable using the play/pause button should also do that :)

Yes, exactly :-)

Presumably, then, we should fire non-cancelable play/pause events whenever we're going to play/pause all of the participating media elements, and audio contexts if we can figure that out.

Hmm, why a non-cancelable event? It seems like a valid thing to do for the author to cancel it if that's what they want!

from mediasession.

foolip avatar foolip commented on August 18, 2024

Hmm, why a non-cancelable event? It seems like a valid thing to do for the author to cancel it if that's what they want!

If you have a pause button, does it ever make sense to not pause? If the event can be canceled, you'd also have to keep any notification UI in sync with that, which seems like a bit of extra work and testing, so there would have to be a reasonable use case IMHO.

Given the semantics I'm suggesting, paused/playing might better names, to be fired after the participating media elements have already been paused/played. If you then play them again in the event listener, it seems you're doing something weird, but at least it'll take all the same code paths as playing it again much later.

from mediasession.

xxyzzzq avatar xxyzzzq commented on August 18, 2024

Closing this issue since we are moving audio focus out to a separate API.

from mediasession.

mounirlamouri avatar mounirlamouri commented on August 18, 2024

@xxyzzzq isn't this for media controls?

from mediasession.

xxyzzzq avatar xxyzzzq commented on August 18, 2024

Sorry, it is.

from mediasession.

mounirlamouri avatar mounirlamouri commented on August 18, 2024

play and pause have been added.

from mediasession.

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.