Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default ST2 app doesn't play sounds after ST2 Native Packaging on Kindle Fire

    ST2 app doesn't play sounds after ST2 Native Packaging on Kindle Fire


    I have developed and successfully tested an ST2 web app using the Chrome desktop browser and various iOS and Android device browsers, including the browser on my Kindle Fire. I used ST2 Native Packaging to build an APK from my web app and then installed the APK on my Kindle Fire and launched it. Everything seems to work fine except my app doesn't play the sounds that it should.

    My app has about 15 short MP3 sound files (between 1 and 10 seconds long) that I load up as xtype: 'audio' items in one of my views. The view is defined as follows:

    Code:
    Ext.define('GessWerd.view.Main', {
        extend: 'Ext.Panel',
        xtype: 'gesswerdMainPanel',
    
        config: {
    ..
            items: [
    ..
                {
                    xtype: 'audio',
                    name: 'sound1',
                    hidden: true,
                    url: 'resources/sound/sound1.mp3'
                },
                {
                    xtype: 'audio',
                    name: 'sound2',
                    hidden: true,
                    url: 'resources/sound/sound2.wav'
                },
    ..
    If I change the 'url:' attribute in the 'audio' declaration to an internet URL (see below), then the natively packaged app does play the sounds as expected on the Kindle.

    Code:
    {
    xtype: 'audio',
    name: 'missSound',
    hidden: true,
    autoPause: false,
    url: 'http://www.spluhdap.com/spluhdap/gesswerd/resources/sound/sound1.mp3'
    }

    The fact that the internet url works but the local, relative url doesn't seems to indicate that I just have to use a different relative url on android but what is the correct relative url?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,811
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What happens when you remove the hidden configs? Do you hear sound then?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default doubt that 'hidden' is the problem

    doubt that 'hidden' is the problem


    Thanks for the reply, I appreciate it. I will try your suggestion tonite but I really doubt that the 'hidden' setting is the problem. I keep the 'hidden' setting on 'true' when I switch the URL to an internet URL and the sound plays correctly. When all the other settings are held constant, why does it work with an Internet URL and fail with a relative (local) URL.

    Earlier in my development process, I mis-named a sound file in a relative url ('sound1.wav' instead of 'sound1.mp3') and I got the same symptom that I see in this case: the sound file did not play. I strongly suspect that when I install the APK on an Android device, it puts the sound files somewhere on the local file system that does not correspond to the relative URL in the 'xtype' audio declaration.

    I even installed ES File Explorer on my Kindle and tried to browse the local file system to find my 'sound1'mp3' file. The ES File Explorer search feature did not find 'sound1.mp3' anywhere on the device.

    I have used 7zip to look inside the APK file generated by Sencha Native Build. It contains an 'assets' folder that contains my ST2 web app, including the sound files:

    assets\resources\sound\sound1.mp3
    assets\resources\sound\sound2.mp3
    ...

    Should I be pre-pending 'assets/' to my sound-file relative URLs on Android native builds? This problem is so frustrating because it seems like I just need to make an adjustment to the relative URL but I don't know what adjustment I should make. Sounds are very important to my app and I can't release it on Android until I get this fixed.

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default prefixing with 'file:///android_asset' doesn't work

    prefixing with 'file:///android_asset' doesn't work


    I have found multiple sources on the web that say to load resources from the 'assets' folder of your APK, you need to prefix the relative URL to that resource with 'file:///android_asset'. I have tried this and it doesn't fix the problem either...

    Tearing my hair out over here...

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default sencha dev team try to reproduce?

    sencha dev team try to reproduce?


    Could someone on the sencha dev team try to reproduce this? you could make a dead simple app that plays a sound from a relative url, package it into an APK and try it. I think you will find that it doesn't work.

  6. #6
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default removing hidden configs didn't work

    removing hidden configs didn't work


    Removing the hidden configs didn't fix the problem. I am testing on the Android emulator (AVD) and my Kindle device. Has someone at Sencha natively packaged an ST2 app that plays xtype 'audio' sounds for Android and successfully tested it? I can provide a simple ST2 app for testing purposes if needed.

  7. #7
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default need help

    need help


    I know you guys are probably very busy but I really need some help with this. I can't ship my app if I can't play sound files out of the APK and I suspect a lot of other ST2 developers either have this problem now or will have it soon.

    What can I do to help the process? I am eager to assist.

  8. #8
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default not an ST2 problem, an android problem

    not an ST2 problem, an android problem


    I took the ST2 xtype 'audio' component out of the picture and added an HTML5 <audio> tag directly to the panel:

    Code:
            html: 
            '<audio preload="auto" id="amiss" src="file:///android_asset/resources/sound/sound1.mp3" type="audio/mp3" />' 
            ,
    and played attempted to play it directly:

    Code:
    var s2 = document.getElementById("amiss");
            s2.play();
    and this also failed.

  9. #9
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default have to use PhoneGap?

    have to use PhoneGap?


    My best information right now is that I have to use the PhoneGap 'Media' class and PhoneGap build if I want to play sound files from an APK. Is that right or is there a way to do this with Sencha Native Build? I would much rather keep it all in the Sencha world but I need to play sounds files from the APK too...

  10. #10
    Sencha Premium Member
    Join Date
    Mar 2008
    Posts
    145
    Vote Rating
    2
    kworam is on a distinguished road

      0  

    Default Using PhoneGap, problem solved

    Using PhoneGap, problem solved


    I have solved my problem using PhoneGap (Cordova-1.5.0) 'Media' class and PhoneGap Build. In the following code, 's' is an ST2 xtype 'audio' component. This is how I handle playing sounds in an Android WebView:

    Code:
    ...
            if (Ext.browser.is.WebView && Ext.os.is.Android)
            {
                this.playAndroidNativeSound(s);
            }
            else
            {
                s.play();
            }
    ...
    
        playAndroidNativeSound: function(s) {
            var src = '/android_asset/www/' + s.getUrl();
            var media = new Media(src);
            media.play();
        },

Thread Participants: 1