eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

Please Add Default Audio Support #688

Closed maxapps closed 8 years ago

maxapps commented 8 years ago

Fantastic job creating Tabris.js; I can't believe more people aren't aware of this tool. I have nine months left on a Telerik AppBuilder subscription but Tabris is already considerably better than NativeScript.

What it really needs is built-in support for playing audio. I know it's possible to add a phonegap but it's a pain in the butt to debug and test. Video is already supported and that would seem to be a less common need on a native app than the ability to play audio.

Personally, I need it to finish converting an HTML5 app created using AppBuilder/Vue.js/Material Design Lite to a native app using Tabris. It will also be needed for most anyone wanting to use Tabris to create games. That might not be the main target for the platform but it certainly seems possible.

gmitros commented 8 years ago

Glad to hear you enjoy working with Tabris.js. Your comment is like balm to our ears... :)

Built-in audio support is of course a reasonable request even if games are not the target. We will try to fit it in the next sprint. Not sure though if we will implement it directly or add an audio plugin to the defaults. The plugin would be accessible in the Developer App so that wouldn't make any difference for testing.

We'll let you know once we have an update on this.

maxapps commented 8 years ago

Glad to hear it. What can we do to help spread the news about this wonderful platform? I've already paid for a developer account but want to help ensure you are able to continue development.

Was able to completely replicate (with exception of audio) a Portuguese language study app in less than five days. Much of the JS code was easily reusable but to develop the UI that quickly while learning a new tool is incredible.

I've written the same basic app on several frameworks as a test to determine usability of them for developing cross-platform applications. The closest I came to creating something usable was a combination of Telerik AppBuilder with Vue.js and Material Design Lite (targeting Android 4). While researching the use of Material Design with LiveScript, I accidentally discovered Tabris. There is work to be done and the documentation could be better but the development cycle with Tabris is much much better than LiveScript and the performance is as advertised. At this point, I see no reason to continue with the LiveScript version of the test app even though I have a paid subscription.

Keep up the great work and thanks for the reply.

On Nov 30, 2015 07:25, "Malgorzata Mitros" notifications@github.com wrote:

Glad to hear you enjoy working with Tabris.js. Your comment is like balm to our ears... :)

Built-in audio support is of course a reasonable request even if games are not the target. We will try to fit it in the next sprint. Not sure though if we will implement it directly or add an audio plugin to the defaults. The plugin would be accessible in the Developer App so that wouldn't make any difference for testing.

We'll let you know once we have an update on this.

— Reply to this email directly or view it on GitHub.

gmitros commented 8 years ago

Thanks so much Jeff for your offer and your kind words.

Your app project that you used for testing the frameworks sounds interesting. If you could possibly write about it in detail and share your experiences with different frameworks in an article / blog post, that would be really amazing. Now, that's time consuming and I'm sure there would be other factors in consideration... Just thought I'd share the idea with you in case it might click :)

In any case, if you can, please rate our Dev App on App Store and Play Store, and star our GitHub repo as that always helps to get more eyes on the project. Thanks!

cookieguru commented 8 years ago

@maxapps What part of adding a plugin was a pain in the butt? I just tried out a very minimal app with cordova-plugin-nativeaudio and it worked as expected.

cordova/config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.plugin.cordova.nativeaudio.demo" version="1.0.0">
    <name>cordova-plugin-nativeaudio-demo</name>
    <description>Tabris.js app with cordova-plugin-nativeaudio plugin</description>
    <author>Me</author>
    <plugin name="cordova-plugin-nativeaudio" version="3.0.6" />
</widget>

And app.js:

tabris.create('Page', {
        title: 'App',
        topLevel: true
}).append(
        tabris.create('TextView', {
                text: 'cordova-plugin-nativeaudio'
        })
).open();

window.plugins.NativeAudio.preloadComplex('mysound',
        'demo.mp3',
        1, // volume
        1, // voices
        0, // delay
        function() {
                console.info('Preload success: ', arguments);
                window.plugins.NativeAudio.play('mysound', function(msg) {
                        console.info('Play success: ', arguments)
                },
                function(msg) {
                        console.warn('Play error: ', arguments);
                },
                function(msg) {
                        console.info('Play complete: ', arguments);
                });
        },
        function(msg) {
                console.warn('Preload error: ', arguments);
        }
);

Toss that in a repo with the a minimal package.json and run a build and everything works. Only downside is the plugin only supports local resources (i.e. no URLs).

Also would be a good time to link this issue to #459

maxapps commented 8 years ago

What part of adding a plugin was a pain in the butt?

Now that I have worked with Tabris for a couple weeks, nothing. Of course, the same thing could be said for any of the built-in features. If something can be done by adding a plugin, why bother including it by default?

At the time, it was just one more thing between me and getting the expected results.

At this point, the number one thing on my wish list would probably be a better way to create JS widgets which could be used in the same manner as the other Tabris widgets (i.e. tabris.create('MyWidget', ...)).

Second to that would be the ability to access any unsupported native feature via JS as is done in NativeScript.

On Thu, Jan 7, 2016 at 5:55 PM, Tim notifications@github.com wrote:

@maxapps https://github.com/maxapps What part of adding a plugin was a pain in the butt? I just tried out a very minimal app with cordova-plugin-nativeaudio https://github.com/floatinghotpot/cordova-plugin-nativeaudio and it worked as expected.

cordova/config.xml:

<?xml version='1.0' encoding='utf-8'?>

cordova-plugin-nativeaudio-demo Tabris.js app with cordova-plugin-nativeaudio plugin Me

And app.js:

tabris.create('Page', { title: 'App', topLevel: true }).append( tabris.create('TextView', { text: 'cordova-plugin-nativeaudio' }) ).open(); window.plugins.NativeAudio.preloadComplex('mysound', 'demo.mp3', 1, // volume 1, // voices 0, // delay function() { console.info('Preload success: ', arguments); window.plugins.NativeAudio.play('mysound', function(msg) { console.info('Play success: ', arguments) }, function(msg) { console.warn('Play error: ', arguments); }, function(msg) { console.info('Play complete: ', arguments); }); }, function(msg) { console.warn('Preload error: ', arguments); } );

Toss that in a repo with the a minimal package.json https://tabrisjs.com/documentation/1.5/getting-started#packagejson and run a build and everything works. Only downside is the plugin only supports local resources (i.e. no URLs).

Also would be a good time to link this issue to #459 https://github.com/eclipsesource/tabris-js/issues/459

— Reply to this email directly or view it on GitHub https://github.com/eclipsesource/tabris-js/issues/688#issuecomment-169833110 .

mpost commented 8 years ago

Since there are multiple audio plugins available as cordova plugins we well include one in the Tabris.js example app so that people can play around with it.

ifurnadjiev commented 8 years ago

Cordova Media plugin has been added to developers app.

jonek commented 8 years ago

We should add this to the description of the next release.

On Tue, Jan 19, 2016 at 12:11 PM, Ivan Furnadjiev notifications@github.com wrote:

Cordova Media plugin has been added to developers app.

— Reply to this email directly or view it on GitHub https://github.com/eclipsesource/tabris-js/issues/688#issuecomment-172819953 .

mpost commented 8 years ago

@ifurnadjiev Do we have an example for it in the cordova examples?

ifurnadjiev commented 8 years ago

There is a pending change waiting for review.

mpost commented 8 years ago

+1

maxapps commented 7 years ago

This issue was pretty much closed but I ended up using TTS instead of pre-recorded audio files for the previous project. Now, I am attempting to create a game using tabris and need the ability to play audio. The code posted above is no longer working at all.

I created a simple test project similar to the one above but using the preloadSimple() method instead of preloadComplex() and it returns an error message stating the file cannot be found.

The bundled script returns: Preload error: {0: "java.io.FileNotFoundException: www/demo.mp3"} Running from a local URL returns: Preload error: {0: "java.io.FileNotFoundException: www/http://192.168.1.3:8080/demo.mp3"}

The cordova plugin (cordova-plugin-nativeaudio) seemed to be adding "www/" to the beginning of the string returned by getResourceLocation(), so I created a new version of the plugin (cordova-tabris-nativeaudio) which is identical but removes the code which prepends "www". This still doesn't work but the error message now indicates what I think is the correct path: Bundled: Preload error: {0: java.io.FileNotFoundException: file:///android_asset/www/bundled_tabris_js_launcher/user_app/demo.mp3"} URL: Preload error: {0: java.io.FileNotFoundException: http://192.168.1.3:8080/demo.mp3"}

The file definitely exists and the mp3 plays correctly if I enter the local URL directly into a browser.

I'm pretty much at wits end and don't understand why this isn't working. Any help would be greatly appreciated.

BTW - There are other cordova plugins which might work but the one I selected (and forked) was written specifically for games (with minimal latency). It's also nice that it doesn't include any unneeded extras such as voice recording, etc.

mpost commented 7 years ago

The path file:///android_asset/www/bundled_tabris_js_launcher/user_app/demo.mp3 is correct for a build app with debug mode turned on. The demo.mp3 is expected to be placed in the www folder of your project.

gmitros commented 7 years ago

@maxapps Were you able to get it to work as in @mpost's comment? Or do you still need help with this?

maxapps commented 7 years ago

No, it absolutely does not work but the @mpost comment just confirmed that the path being presented by the java io error is indeed the correct path.

I was able to add sound using the cordova media plugin (included in the developer app) but it is far from perfect. For one thing, the resource is not loaded until you actually call the plugin's play() method. This results in a short delay before any sound comes out the speaker. This is completely unacceptable when producing audio for gaming purposes because it's very noticable when the sound of spaceship exploding happens a couple milliseconds after you see it crash. The nativeaudio plugin was created as a solution to this problem but it hasn't been updated in several months and appears to have been written for a much older version of cordova.

I always thought that "borrowing" cordova plugins to provide additional functionality was a brilliant move on the part of the tabris team but now I'm not so certain. When plugins change and/or do not get updated, core functionality may no longer work. Cordova plugins were created to provide functionality which doesn't exist in the browser but new versions of the HTML spec are adding built-in support for things like the camera. If the plugins don't get updated because they are no longer needed for HTML apps, where does that leave tabris?

For now, I have created a simple JS module which mitigates the delay issue by preloading the sounds in a rather cheesy manner. Each sound file is actually played for a very short duration and is then stopped using code in the update event handler. This actually works but is certainly not optimal. Someone with more detailed java/cordova knowledge could probably update the nativeaudio plugin to make it functional but that's outside my current skill set. If this experiment in creating games with tabris seems worth continuing, I will probably spend a week or two addressing the nativeaudio plugin myself.

Unfortunately, I am also encountering other issues which don't appear until you start doing things which are game-specific. One of them is a strange problem where the devloper app locks up completely when the "Start" button on the menu page is tapped. The game will intermittently (60% of the time) lock up to the point that the developer console cannot be opened and code running in a window.setInterval() loop no longer executes. This sounds like some kind of infinite loop issue but the fact that it is intermittent makes it difficult to troubleshoot. It did start around the time the funky code for preloading sound files was added but I am not completely certain they are related.

Overall, I still think tabris is a great idea and worth using for its intended purpose.

cookieguru commented 7 years ago

@maxapps Are you calling preloadSimple()? Does your app work any better with cordova-plugin-media?

maxapps commented 7 years ago

@cookieguru

Are you calling preloadSimple() ?

Yes, when attempting use the nativeaudio plugin, I was calling preloadSimple() but I also experimented with preloadComplex() and it no longer worked either. The error was slightly different but it didn't work.

As mentioned above, it was working at one point in an earlier app but I think the plugin was modified by the developer. I stopped using nativeaudio in that app and switched to a text-to-speech plugin instead. Now, when attempting to use nativeaudio again, it no longer works. According to the java io error, there's no way it can work because the path is being prepended with an extra 'www/'. Unfortunately, my modified version of the plugin also fails even though the path reported by the error is correct.

Does your app work any better with cordova-plugin-media?

It works for testing purposes but not for production. Please see my long-winded explanation above.

mpost commented 7 years ago

@maxapps Sorry to hear that you are still having problems with these audio plugins. Regarding your comment of cordova plugin support for native functionality: We will introduce tabris specific functionality if the browsers add support for eg camera.

Regarding your second problems... running the timer example works fine with the setInterval function. Is that maybe related to the audio plugin?