Can libopenmpt.js to be used like WebPJS?

Started by RyanBram, July 31, 2018, 15:41:59

Previous topic - Next topic

RyanBram

Hi.

If we want use WebP for unsupported browser, there are solution in .js  that as a fallback if browser is not supporting the format.
Based on the WebPJS web, the solution looks like as simple as putting the script:
<script>(function(){var WebP=new Image();WebP.onload=WebP.onerror=function(){
if(WebP.height!=2){var sc=document.createElement('script');sc.type='text/javascript';sc.async=true;
var s=document.getElementsByTagName('script')[0];sc.src='js/webpjs-0.0.2.min.js';s.parentNode.insertBefore(sc,s);}};
WebP.src='data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';})();</script>


Is it possible to do the same thing with libopenmpt.js which make module music integration in website as natural as possible like more common format, such as mp3, vorbis and aac? I don't need advanced feature like common media player (volume slider, playlist, seekbar, etc). I just want to throw some random module music in my web and it play just like my browser do with mp3.

Thanks.

Saga Musix

Most likely this requires a lot of work with arguably little gain, which we are certainly not going to do. You can have a look into cowbell.js if you want a unified player component for many formats.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

RyanBram

#2
How about something like https://github.com/wothke/webMPT ?
and
https://github.com/wothke/webaudio-player
Can it be used to connecting libopenmpt.js with HTML5 seamlessly?

Edited:

Recent search also bring me to this web http://audiocogs.org/articles/2012/06/15/flac-and-aurora/

Does it mean that aurora.js also one of the alternative for connecting libopenmpt.js to web?

manx

It might be a good idea to clarify naming and scope of various things here.

There is no project called "libopenmpt.js". What we provide is a compiled "binary" or artifact (or the equivalent thing for the respective platform) compiled for a specific development environment, in particular also for JavaScript. This compiled artifact is called "libopenmpt.js". Because "libopenmpt.js" is nothing more but a compiled artifact of libopenmpt, it does not do a single thing more as other compiled binaries of libopenmpt would do on other platforms. It exposes its own documented interface and nothing else.

libopenmpt also does not by itself support players like WinAMP, XMPlay, or foobar2000. What is shipped with libopenmpt are separate things like in_openmpt, xmp-openmpt, or foo_openmpt respectively which make use of libopenmpt and connect it to the plugin interfaces of the respective players.

It would not make sense for libopenmpt itself to provide such specific interfacing support for HTML5 <audio>. In particular, libopenmpt.js can also be used on other platforms that provide a JavaScript VM (like node.js) which do not even provide any HTML5 context.

Now, can an adapter to provide a HTML5 <audio> shim for libopenmpt be written?
Yes, absolutely, and for someone familiar with current web technology, this would probably even be rather simple. However such things are out of scope for the libopenmpt project itself. Other people who are more knowledgeable about the specific target environment have written player plugins for other audio players like qmmp or gstreamer, or even players for the web platform (see a bigger list here https://wiki.openmpt.org/Libopenmpt). Thus it just needs someone to write the HTML5 <audio> adapter. The goal of libopenmpt is to make it possible be used in various environments and not to provide that finished solution already (unless in cases where the libopenmpt developers themselves are familiar enough with a specific environment to provide such support directly, which is the case for WinAMP, XMPlay and (less so) foobar2000).

Now, some libraries include a certain amount of platform specific interfacing and shim support directly when building for specific platforms like when using emscripten to target JavaScript. Others provide a somewhat separate set of language- or platform-specific bindings. Even others do not provide such things themselves and rely on third party developers to provide such things as separate projects. libopenmpt falls in the last category. Providing such things directly with libopenmpt would require being able to test them in order to guarantee the amount of stability and bug-freeness that we want to provide for our project. However, I am not confident enough that I would be able to do that for a platform as fast-changing as the web platform, thus I'd rather not include such things in libopenmpt directly and continue to rely on other people to step up and provide such things, even if that means that such things might not adhere to the quality standard I would like them to have, or not even exist at all.

I am not sure if aurora.js may be of any help in developing a libopenmpt HTML <audio> wrapper. It might be or it might not (it might be more tailored towards streaming formats and decoders written directly in JavaScript instead of compiled to JavaScript).

As to whether other projects provide HTML5 integration for libopenmpt, it is probably a better idea to ask them (to my knowledge, none of them do, but my knowledge may be incomplete). It might even be that they have not even considered <audio> support yet and might implement it after your suggestion.

Saga Musix

webMPT is just another frontend like the existing chiptune2.js or cowbell.js.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

RyanBram

Ok.
Thank you very much Saga and Manx for the explanation.