On 6/23/13 12:39 PM, Alive Kuo wrote:
> David,
>
Thank you for moving this forward, Alive!
> With Andrea's effort on bug 853101, system app would gain the power to
> control play/pause of certain app.
>
I don't see that yet in
https://wiki.mozilla.org/WebAPI/AudioChannels,
but I assume that Andrea is adding a play/pause feature in the bug
itself and the wiki is just out of date.
What we need in addition to that low-level API is a meta-level of
control so that we can send application-level commands like
"next-track". I wonder if there is any way we can justify adding that
feature to the AudioChannels API itself. I'm not at all sure that that
is a good idea, but consider this use-case: when an alarm sounds, it
would be nice to allow the user to snooze or silence it from the
lockscreen. (I suspect we already do that, actually). But a very clean
way to do that would be to send a meta-command "snooze" from the
lockscreen to the clock app.
> However, as previous discussion, we still lack two important things:
>
> 1) How to identify the media player?
In my first draft of the API I proposed, there was an explicit
navigator.something API for the music player to use. Then I tried to
integrate that API directly on to the HTMLMediaElement. In retrospect, I
think that was probably a mistake. So if we define a MediaControl API,
identifying the player will be easy: its the app that uses the player
part of the API.
> 2) How to communicate?
> (A) From music to system (Update the playing song tittle….)
> (B) From system to music (Part of this would be achieve with new
> audio channel API)
>
Note that the draft UX designs we have for music app controls on the
lockscreen call for album art, so the player app to controller app
communication channel has to be able to pass blobs.
> I don't know the detail of so called 'inter-app communication API'…is
> it ongoing?
> in case we in the long don't have this magical stuff,
> I still have some ideas about these two questions, in a mid-term way.
>
If we are going to get some kind of inter-app communication API, I think
that would be the best way to proceed here.
I'd even suggest hacking something together (using the settings API for
communication and saving album art to device storage instead of
transferring that through settings) while we wait for an inter-app
communications API.
> The proposal is still my first proposal, using window.open(...) in
> music app,
> "but" system app won't bring the opened frame to foreground. (Because
> people hate to have too many frame in foreground:)
>
If this mechanism only allows communication between apps and the system
app, and it does not actually open a visible window (i.e. if it is not
some kind of generic widget feature) then it seems like there ought to
be a simpler way, like allowing postMessage and onmessage for
communication with the system. Perhaps I'm mis-understanding the
nuances of your proposal, Alive.
David
> So it is to say, let music app open a "background media player frame"
> to let system app knows it would like to be controlled.
>
> System app would then check the (1) content channel permission and (2)
> is it playing?(Using audio channel API).
>
> The opened frame could also be used for communication to system,
> and system would use mozBrowser API to get event when it changes
> something(like title-change, uh, weird I know.)
>
> This helps system app to identify who is going to be controlled, and,
> if multiple apps are going to be controlled,
> the key to find whom is relied on the app switch mechanism in system
> app(window manager) to find who is active app and playing content and
> having an opened 'media-player-background-frame' now.
>
> Also if we are lucky to have the inter-app communication API, the
> opened frame could be ignored here.
> Just use the brand new communication API!
> But it's still necessary to make music app to let system knows he is
> going to play content,
> and I think this also solves the cases some app are using content
> channel but won't be controlled via lock-screen controller.
> --
> Alive C. Kuo, Front-end Eng., Mozilla Corp. (Taiwan, Taipei)
>
> Andrea Marchesini <
amarc...@mozilla.com