App.sound_effect = App.cable.subscriptions.create('SoundEffectChannel', { connected: function() {}, disconnected: function() {}, received: function(data) { var hostname = location.hostname.trim(); if(data.from == "" || hostname == data.from){ var shop_code = data.shop_code; var audio = data.audio; var data = data.data; if(data.status){ var audio = new Audio('/'+audio); // define your audio audio.play(); } if(data.status && ((data.message != undefined) && (data.message!=""))){ swal({ title: 'Information', text: data.message, type: 'success', html: true, closeOnConfirm: false, closeOnCancel: false, allowOutsideClick: false }, function (isConfirm) { if(isConfirm){ swal.close(); } }); } } } });