{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/mediasession/issues/40","labels_url":"https://api.github.com/repos/whatwg/mediasession/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/mediasession/issues/40/comments","events_url":"https://api.github.com/repos/whatwg/mediasession/issues/40/events","html_url":"https://github.com/whatwg/mediasession/issues/40","id":78106365,"number":40,"title":"MediaSession auto-connection seems weird","user":{"login":"tabatkins","id":682840,"avatar_url":"https://avatars.githubusercontent.com/u/682840?v=3","gravatar_id":"","url":"https://api.github.com/users/tabatkins","html_url":"https://github.com/tabatkins","followers_url":"https://api.github.com/users/tabatkins/followers","following_url":"https://api.github.com/users/tabatkins/following{/other_user}","gists_url":"https://api.github.com/users/tabatkins/gists{/gist_id}","starred_url":"https://api.github.com/users/tabatkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tabatkins/subscriptions","organizations_url":"https://api.github.com/users/tabatkins/orgs","repos_url":"https://api.github.com/users/tabatkins/repos","events_url":"https://api.github.com/users/tabatkins/events{/privacy}","received_events_url":"https://api.github.com/users/tabatkins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-19T14:15:43Z","updated_at":"2015-05-19T16:19:31Z","closed_at":null,"body":"As far as I can tell, there are at most four MediaSession objects in existence, one per kind that appears in the page.  Media objects get assigned the appropriate one to their `.session` property automagically based on their `.kind` property.\r\n\r\nThis seems weird.  You're really assigning media objects to mutually-exclusive sets; the set they belong to determines how they behave wrt media focus and events.  Why not reify this pattern directly?  Add a global somewhere (`window.mediaSessions`?) with four set-likes hanging off of it statically with appropriate names, which you can add media objects to. To maintain mutual-exclusivity, I guess the add() method on the set-likes needs to check for the presence of its argument in the other sets, and remove it automatically.  Then you can pretend to have a MutationObserver looking for `kind=''` attribute changes and translating them into `.add()` on the appropriate set-like.\r\n\r\nIf people need to know which set a media object is in, they can either check `.has()` on the various ones, or we can expose a static method on the global that just tells you.  Or keep `.kind` on media objects as a readonly that reflects the membership."},"comment":{"url":"https://api.github.com/repos/whatwg/mediasession/issues/comments/103574680","html_url":"https://github.com/whatwg/mediasession/issues/40#issuecomment-103574680","issue_url":"https://api.github.com/repos/whatwg/mediasession/issues/40","id":103574680,"user":{"login":"tabatkins","id":682840,"avatar_url":"https://avatars.githubusercontent.com/u/682840?v=3","gravatar_id":"","url":"https://api.github.com/users/tabatkins","html_url":"https://github.com/tabatkins","followers_url":"https://api.github.com/users/tabatkins/followers","following_url":"https://api.github.com/users/tabatkins/following{/other_user}","gists_url":"https://api.github.com/users/tabatkins/gists{/gist_id}","starred_url":"https://api.github.com/users/tabatkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tabatkins/subscriptions","organizations_url":"https://api.github.com/users/tabatkins/orgs","repos_url":"https://api.github.com/users/tabatkins/repos","events_url":"https://api.github.com/users/tabatkins/events{/privacy}","received_events_url":"https://api.github.com/users/tabatkins/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T16:19:31Z","updated_at":"2015-05-19T16:19:31Z","body":"I don't see how author-created sessions come into being or are used.  There's no constructor on MediaSession, and `.session` on media objects is readonly and appears to get set automatically by setting `.kind`.  It's possible I'm completely missing something explained in one of the algorithms, but the two examples seem to just be auto-assigning them to some UA-created sessions.\r\n\r\nMaybe this just needs significantly improved explanations scattered through the spec; right now I don't understand what most of the algorithms are meant for.  For example, I'm still not sure where the media key events get routed to your element."}}