sencha-touchsencha-touch-2sencha-touch-2.1

Play Audio in Sencha app with external url


I am new to sencha and I am trying to add audio player to my app, where the url for audio is an external link. here is the code I used

{
            xtype:'audio',
            url:'http://dl.enjoypur.vc/upload_file/5570/6757/%20Bollywood%20Hindi%20Mp3%20Songs%202015/Prem%20Ratan%20Dhan%20Payo%20(2015)%20Mp3%20Songs/02%20Prem%20Ratan%20Dhan%20Payo%20%28Title%20Song%29%20Palak%20Muchhal%20-%20190Kbps.mp3',
            title:'Sample MP3',
            thumb:'media/sample.jpg'
        },

App shows me a audio player in view, but that is just unresponsive and doesn't play. is there a way to insert audio from external link?

Thanks in advance


Solution

  • It would be really helpfull if you share more of your code in matter to find the bug. Well this works for me:

    Ext.create('Ext.Container', {
    fullscreen: true,
    layout: {
        type: 'vbox',
        pack: 'center'
    },
    items: [
        {
            xtype : 'toolbar',
            docked: 'top',
            title : 'Ext.Audio'
        },
        {
            xtype: 'toolbar',
            docked: 'bottom',
            defaults: {
                xtype: 'button',
                handler: function() {
                    var container = this.getParent().getParent(),
                        // use ComponentQuery to get the audio component (using its xtype)
                        audio = container.down('audio');
    
                    audio.toggle();
                    this.setText(audio.isPlaying() ? 'Pause' : 'Play');
                }
            },
            items: [
                { text: 'Play', flex: 1 }
            ]
        },
        {
            html: 'Hidden audio!',
            styleHtmlContent: true
        },
        {
            xtype : 'audio',
            hidden: true,
            url   : 'http://dl.enjoypur.vc/upload_file/5570/6757/%20Bollywood%20Hindi%20Mp3%20Songs%202015/Prem%20Ratan%20Dhan%20Payo%20(2015)%20Mp3%20Songs/02%20Prem%20Ratan%20Dhan%20Payo%20%28Title%20Song%29%20Palak%20Muchhal%20-%20190Kbps.mp3'
        }]
    });
    

    Also I highly recommend the Touch documentation with examples Tested within fiddle. Pretty nice music. I like this Oriental type of music. I hope it helps you :-)