MIDI.js icon indicating copy to clipboard operation
MIDI.js copied to clipboard

midi js in android webview

Open mrweix opened this issue 11 years ago • 15 comments

Hello!

I am integrating midi.js in a phonegap app that is based on a webview. For ios where the webview is based on Safari this works great! thanks!

For android however the webview is based on WebKit-based WebView (up to Android 4.4) and Chromium (Android 4.4 and higher) . All the sources are loaded but it just won't play a sound...... On Android 4.4 it works on Chrome Browser but not on the Chromium web view

Debugging also doesn't show any mistakes....loads the midi object correctly and display for api: for android 4.1.2 (webkit webview) the api: "audiotag" for android 4.4 (chromium) the api: "webaudio" (same as chrome on )

Any ideas if this can be fixed with a workaround or if this is a problem of midi.js?

mrweix avatar Feb 12 '15 23:02 mrweix

Greetings! I have similar needs, midi.js in phonegap. I'll be generating local midi, so either need to pass a var (preferrably) or local file. Any ideas on how I should proceed, without having to modify midi.js?

QuinDennis avatar Feb 16 '15 16:02 QuinDennis

Found it in the dev branch, midi.USE_XHR=false

QuinDennis avatar Feb 16 '15 22:02 QuinDennis

I don't quite understand.... how do you propose this can be fixed? And where should one fix the midi.USE_XHR=false ?

mrweix avatar Feb 16 '15 22:02 mrweix

https://github.com/mudcube/MIDI.js, select the dev branch, download, in plugin.js set USE_XHR=false.

midi.DEBUG = false; //midi.USE_XHR = true;

midi.USE_XHR = false;

Then, the MIDIPlayer.html example works and playing notes in Chrome works. Haven't moved it to phonegap yet but believe it will work there also.

I'm not totally clear this solves your issue, but I'm good to go now! (I think)

QuinDennis avatar Feb 16 '15 22:02 QuinDennis

Mmmh I tried it and still no sound on android.....

Please let me know if you have it working with Phonegap.

mrweix avatar Feb 16 '15 23:02 mrweix

We also included the file acoustic_grand_piano-ogg.js within a

On 2/16/2015 5:09 PM, mrweix wrote:

Mmmh I tried it and still no sound on android.....

Please let me know if you have it working with Phonegap.

— Reply to this email directly or view it on GitHub https://github.com/mudcube/MIDI.js/issues/122#issuecomment-74586820.

Quin Dennis | 512-392-8619

QuinDennis avatar Feb 19 '15 03:02 QuinDennis

Oh, and yes, it works in Phonegap.

On 2/16/2015 5:09 PM, mrweix wrote:

Mmmh I tried it and still no sound on android.....

Please let me know if you have it working with Phonegap.

— Reply to this email directly or view it on GitHub https://github.com/mudcube/MIDI.js/issues/122#issuecomment-74586820.

Quin Dennis | 512-392-8619

QuinDennis avatar Feb 19 '15 03:02 QuinDennis

Thanks guys for all the input. I follow all the steps you recommend include the dev branch, include the soundfont files, everything works fine in Phonegap, but as soon as I bring it to an Android device: QUIET....I have no idea. Debugging and everything doesn't show any error. It just doesn't play a sound.... this is android 4.4 and 4.1 ...... on which android devices can you make it play a sound?

mrweix avatar Feb 19 '15 19:02 mrweix

Hi, yes, we're running into issues on a NextBook 8 as well. My Samsung G4 plays sounds but not as clearly as the browser, so we're still researching, in the area of SoundFont files, etc. Will keep you in the loop if/when we find something.

On 2/19/2015 1:38 PM, mrweix wrote:

Thanks guys for all the input. I follow all the steps you recommend include the dev branch, include the soundfont files, everything works fine in Phonegap, but as soon as I bring it to an Android device: QUIET....I have no idea. Debugging and everything doesn't show any error. It just doesn't play a sound.... this is android 4.4 and 4.1 ...... on which android devices can you make it play a sound?

— Reply to this email directly or view it on GitHub https://github.com/mudcube/MIDI.js/issues/122#issuecomment-75120679.

Quin Dennis | 512-392-8619

QuinDennis avatar Feb 19 '15 21:02 QuinDennis

Great! Appreciate it!

mrweix avatar Feb 19 '15 21:02 mrweix

I tried some more and no luck. It really comes down to a problem of midi.js talking to Chromium. On Chrome I got it working, but Chromium seems to have some slight changes the way ogg audio is handled in the webaudio api.....anybody else has an idea how to make this work?

mrweix avatar Mar 03 '15 15:03 mrweix

I recently tried with phonegap with http://www.telerik.com for hybrid mobile app, I am using loop to play sequence of notes, it plays but not with perfect timing and some times some notes does not create sound. Anybody got it working perfectly with phonegap?

shivrajsa avatar Aug 12 '15 11:08 shivrajsa

Hi, I also have a similar problem : I would like to use the player of midi.js in a Crosswalk webview (which uses chrome for android) but it doesn't play any sound. And I have no idea what is happening since the console doesn't show error.. Is there someone who figured out how to solve this problem? or does someone see what is happening?

braoul avatar Sep 27 '15 05:09 braoul

Same problem here: Not work with ionic/cordova in android 4.1 and 4.4. I saw in 'loader.js' line 50 "root.audioDetect", chose between 'webmidi', 'webaudio' and 'audiotag'. Always selects audiotag, but in android 5.0, it selects 'webmidi';

Finally seeing 'plugin.audiotag.js' line 41, when execute 'audio.play()' emits no sound ;

anyone?

acosme avatar Aug 11 '16 22:08 acosme

Also same problem working on midi.js. It works fine when running it on desktop browser but when running it on android webview things were different, it plays but no sound. I'm new to android and hopefully you can help me guys.

kentoii17 avatar May 08 '18 23:05 kentoii17