Create Sound.jsm for Android

RESOLVED FIXED

Status

()

Firefox for Android
General
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: mcomella, Assigned: mcomella)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

And look how this might tie into the pre-existing nsISound interface [1].

[1]: https://mxr.mozilla.org/mozilla-central/source/widget/nsISound.idl
Created attachment 8452777 [details] [diff] [review]
(WIP) Add Sound.jsm for Fennec.

This patch creates an abstraction layer to load and play Sounds using webaudio.

An add-on using the module can be found at:

https://github.com/mcomella/sound-jsm-test/tree/v1
Comment on attachment 8452777 [details] [diff] [review]
(WIP) Add Sound.jsm for Fennec.

Looks pretty good. I'm not sure how Promises would improve the API. Might be worth a look.

Rename: loadFile -> loadURI
Attachment #8452777 - Flags: feedback?(mark.finkle) → feedback+
Created attachment 8456543 [details] [diff] [review]
Add Sound.jsm for Fennec

This version fixes an issue where the module would only work if the addon was
installed with the browser already fully loaded by using lazy context getters.
This has a side effect of making the first play of most sound effects not
playing, which can be fixed with an observer. I thought this complicated the
code a bit too much, so I opted to leave it out for this version.
Attachment #8456543 - Flags: feedback?(mark.finkle)
Comment on attachment 8456543 [details] [diff] [review]
Add Sound.jsm for Fennec

Sound.jsm looks good. I don't know where we want to put it yet though. Let's talk to Margaret (or someone) about creating a mozilla/addons (or similar) on github where we can add cool helper modules like this one.
Attachment #8456543 - Flags: feedback?(mark.finkle) → feedback+
Flags: needinfo?(margaret.leibovic)

Comment 5

4 years ago
(In reply to Mark Finkle (:mfinkle) from comment #4)
> Comment on attachment 8456543 [details] [diff] [review]
> Add Sound.jsm for Fennec
> 
> Sound.jsm looks good. I don't know where we want to put it yet though. Let's
> talk to Margaret (or someone) about creating a mozilla/addons (or similar)
> on github where we can add cool helper modules like this one.

I would love to make a github repo for handy add-on scripts. I have the power to make a new repo on the mozilla account, but maybe we should give it a Fennec/Android specific name if it's just going to hold code that will work for Fennec add-ons.

Jorge, do you know if there's already a place where add-on authors share scripts with each other?

I also wonder if we could add this to the add-on SDK.
Flags: needinfo?(margaret.leibovic) → needinfo?(jorge)
There's an MDN page that lists all useful JSMs in Firefox code: https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules. If Sounds.jsm makes sense for Firefox as well, then I would suggest putting it in a more general location and documenting it on MDN.

We don't have a single place for sharing scripts. The mozilla github repo would be a good place, and we can help to broadcast the message.
Flags: needinfo?(jorge)
Jorge, how might we get this jsm into the mozilla github repo?
Flags: needinfo?(jorge)
There's info about our github repo here: https://wiki.mozilla.org/Github. I think it's just a matter of contacting the owners list to set up the repo for you.
Flags: needinfo?(jorge)

Comment 9

4 years ago
I have the powers to create repos in the mozilla account. I could a make a new repo for Fennec add-on goodies. We could put mfinkle's skeleton add-on and my hub boilerplate add-on in there as well, to give those a more official home.

What should we name the repo? mobile-addons? fennec-addons?

I propose we have one top-level directory for helper scripts (that's where Sound.jsm) could live, another top-level directory for boilerplate/skeleton code (that's where the skeleton/hub boilerplate add-ons could live), and another top-level directory for some example add-ons. We could also link to a bunch of known open source add-on examples in the README.

What does everyone think of this plan?
Sounds good to me.

(In reply to :Margaret Leibovic from comment #9)
> What should we name the repo? mobile-addons? fennec-addons?

I don't like mobile-addons because it could be conflated with b2g. fennec-addons could be nice, but I'm concerned how many people are familiar with Firefox for Android's codename.

I would vote `android-addons` or, since I'm slightly concerned people may interpret "android-addons" as addons to the OS, `firefox-for-android-addons`.

Comment 11

4 years ago
(In reply to Michael Comella (:mcomella) from comment #10)
> Sounds good to me.
> 
> (In reply to :Margaret Leibovic from comment #9)
> > What should we name the repo? mobile-addons? fennec-addons?
> 
> I don't like mobile-addons because it could be conflated with b2g.
> fennec-addons could be nice, but I'm concerned how many people are familiar
> with Firefox for Android's codename.
> 
> I would vote `android-addons` or, since I'm slightly concerned people may
> interpret "android-addons" as addons to the OS, `firefox-for-android-addons`.

Done!

https://github.com/mozilla/firefox-for-android-addons

You should have permission to push to it. I created /modules and /boilerplate directories. Feel free to add stuff (and improve the README files).
I have added Sound.jsm to the github repo:

https://github.com/mozilla/firefox-for-android-addons/tree/master/modules
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Filed bug 1059534 to flesh out the support code around Sound.jsm.
You need to log in before you can comment on or make changes to this bug.