Comments (20)
Do you mean to trigger the default actions for when a media session is interrupted and then resumes again?
from mediasession.
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.
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.
Ah, right. Thanks for the clarification.
Adding play()
and pause()
methods to MediaSession
objects sounds doable as a convenience feature.
from mediasession.
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.
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.
As far as the MediaSession is concerned, I think play/pause button should resume/interrupt the session.
from mediasession.
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.
I think that's sufficient, but ideally @ehsan or @sicking confirms.
from mediasession.
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.
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.
Wait, not methods, events on MediaRemoteControls
.
from mediasession.
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.
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.
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.
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.
Closing this issue since we are moving audio focus out to a separate API.
from mediasession.
@xxyzzzq isn't this for media controls?
from mediasession.
Sorry, it is.
from mediasession.
play
and pause
have been added.
from mediasession.
Related Issues (20)
- Top issues for TPAC 2023 HOT 2
- Add WPT mediasession permission policy tests HOT 1
- Should the default mediasession permission policy value be self instead of * HOT 4
- MediaPositionState IDL does not allow infinite duration HOT 1
- How should Media Session work with "inert" media? HOT 6
- Should there be a toggle screenshare action? HOT 5
- What is the relationship between toggle microphone/camera actions and MediaStreamTrack mute/unmute events? HOT 11
- setPositionState: Explicit means to "clear" or reset. HOT 5
- Introduce a MediaSession task source HOT 1
- Support multiple devices to support Video Conferencing use cases HOT 20
- Should toggle capture actions expose the new capture state?
- Details dictionary parameters description could be more precise HOT 1
- #320 broke IDL: MediaSessionActionHandler can only use the base MediaSessionActionDetails but not any extensions
- Broken references in Media Session
- Replace uses of "browsing contexts" with "navigables"?
- [SameObject] should not be used in FrozenArray attributes HOT 5
- Using MediaSession without playing audio? HOT 2
- MediaSessionActionHandler callback's type is never correctly chosen HOT 2
- The update capture state algorithm needs refinement HOT 2
- The spec should state that capture related actions should generally have a source target
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediasession.