This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

.play() and Chrome !
#1
Hi,

This script works perfectly with IE and Firefox but not with Chrome (Win. and Android).

Someone would have an idea for this problem ?


Code:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" version="1.1" baseProfile="full" viewBox="0 0 0 0" id="root">
 
 <defs>
   <script type="text/javascript">
   <![CDATA[
    var p = window.parent, root, addr;
    var ip = location.host;
    var audio0 = "http://192.168.1.10/scada/resources/img/";
         root = document.getElementById('root');
            if (p && p.objectStore) {
                addr = p.Scada.encodeGroupAddress('0/0/202');
                p.objectStore.addListener(addr, function (obj) {
                    
                    if (obj.value !== 0) {
                        var snd0 = new Audio("" + audio0 + obj.value + "_on.mp3");
                        snd0.play();
                    }
                                        
                });
            }

   ]]>
   </script>
 </defs>
</svg>

Regards,
JMM.
Jean-Marc
Reply
#2
Please check what kind od error is in the console.
Reply
#3
Thanks for the help

No error in the console. Sad
Jean-Marc
Reply
#4
Chrome requires some kind of user interaction before audio can be played. See this post for a work-around:
https://forum.logicmachine.net/showthrea...49#pid2449

If you need a simple "beep" sound, you can try this example:
https://forum.logicmachine.net/showthrea...16#pid1616
Reply
#5
.play(), works very well in a simple page HTM with Chrome, but once integrated into LM do not work any more.

With IE or Firefox is OK !.

JMM.

Thanks Admin !

I need to read alerts in MP3 and;
https://forum.logicmachine.net/showthrea...49#pid2449
is for IOS not Android or Win.
Sad
Jean-Marc
Reply
#6
HI,

with this script added into the custom javascript, it is OK for:

-Firefox and Chrome (windows)
-Firefox (Android)

And always bad for Chrome (Android) !!
an idea? Sad

Code:
//-------ALARME MP3--------------------------------------  
 
 
      var p = window.parent, root, addr;
     var audio0 = "http://192.168.1.10/scada/resources/img/";
        root = document.getElementById('root');
            if (p && p.objectStore) {
                addr = p.Scada.encodeGroupAddress('0/0/202');
                p.objectStore.addListener(addr, function (obj) {
                    
                    if (obj.value !== 0) {
                        var snd0 = new Audio("" + audio0 + obj.value + "_on.mp3");
                        snd0.play();
                    }
                });
            }
//--------------------------------------------------------
 
Jean-Marc
Reply
#7
Hi!
For the people which would be interested in this problem, that's why Chrome does not answer has .play() !

https://bugs.chromium.org/p/chromium/iss...?id=178297


Here is the solution to disable the user gesture. Big Grin Big Grin

Chrome for Android: You can disable the 'gesture required' flag by going to 'about:flags' in your chrome. Then find the flag 'disable gesture requirement for media playback' and click 'enable', at the bottom of the page box will appear that says 'Your changes will take effect the next time you relaunch Google Chrome' and a button 'Relaunch Now'. Click the button. You can now start videos via javascript.
For some reason this seems to be the best kept secret on the Internet. I searched for months before finding this.

Regards,
JMM.
Jean-Marc
Reply


Forum Jump: