Могу ли я реализовать автоматическое воспроизведение аудиофайла с помощью Pusher Real Time - PullRequest
0 голосов
/ 18 февраля 2020

Можно ли автоматически воспроизводить аудиофайл при отправке данных с помощью Pusher?

$("#sound_tag").get(0).play();

$(document).ready(function(){
            // CALL FUNCTION SHOW PRODUCT
            

            show_product();

            // Enable pusher logging - don't include this in production
            Pusher.logToConsole = true;
 
            var pusher = new Pusher('e1b363d24b7d8f6b4f70', {
                cluster: 'ap1',
                forceTLS: true
            });
 
            var channel = pusher.subscribe('my-channel');
            channel.bind('my-event', function(data) {
                if(data.message === 'success'){
                    show_product();
                    //voice_message();
                }
            });

 
            // FUNCTION SHOW PRODUCT
            function show_product(){
                $.ajax({
                    url   : '<?php echo site_url("Main/get_display");?>',
                    type  : 'GET',
                    async : true,
                    dataType : 'json',
                    success : function(data){


                        var html = '';
                        var count = 1;
                        var i;
                        for(i=0; i<data.length; i++){
                            html += '<tr>'+
                                    '<td hidden="true">'+ count++ +'</td>'+
                                    '<td hidden="true">'+ data[i].ticket_id +'</td>'+
                                    '<td style="text-align: center; background-color: black;"><strong style="font-size: 97px; font-weight: bold; color: yellow; font-family:verdana; "><p style="font-size: 20px;">Ticket No.</p>'+ data[i].ticket_no +'</strong></td>'+
                                    '<td style="text-align: center; background-color: black;"><strong style="font-size: 97px; font-weight: bold; color: yellow; font-family:verdana; ">'+ data[i].proceed_to +'</strong></td>'+
                                    '</tr>';
                        }
                        $('.show_product').html(html);
                        $("#sound_tag").get(0).play();
                    }
 
                });

            }
        });
...