Is there a way to detect if a device can't play audio?

Get help using Construct 2

Post » Tue Feb 24, 2015 7:06 pm

Is it possible to check if the device your app is running on can't play music, so that I can then remove any icons associated to that?
Some games: https://play.google.com/store/search?q= ... s&hl=en_GB Feel free to show the panda some support, he would appreciate it :)
B
19
S
5
G
1
Posts: 155
Reputation: 1,619

Post » Tue Mar 17, 2015 9:32 am

Sometimes, we need to remove sound from the problem devices like galaxy s3, sharp, xperia Z , and hide audio button on them.
I found a solution for that.
First, we need to add an events and global variable to a project:
disablesound.png


Then, we need to export the game and add a code to the index.html

Code: Select all
// Create new runtime using the c2canvas
         cr_createRuntime("c2canvas");

//put a code right here in your index.html

});



//CODE
var ua = navigator.userAgent.toLowerCase();
      var isSthree = ((/gt-i9300|gt-i9305|gt-i9301|sgh-n064|sgh-n035|sch-j021|sgh-t999l/i).test(ua));
      var isSharp = ((/SHL24|SHL23|SHL22|SHL25|SHL21/i).test(ua)) && !/(firefox|opera|chrome)/i.test(ua);
      var isXperia = ((/D6603|D6616|D6633|D6643|D6653|L55t|L55u|D6708/i).test(ua)) && !/(firefox|opera|chrome)/i.test(ua);
      var isXperiaZ = ((/C6602|C6603|C6606|C6616|SO-02E/i).test(ua)) && !/(firefox|opera|chrome)/i.test(ua);
      var isIE10 = /MSIE 10/i.test(navigator.userAgent);
      var isTest = false;
      // var isTest = false;
      
      delete sessionStorage.rm_disablesound;

      if (typeof (Storage) !== "undefined")
      {
        if(isSthree || isSharp || isIE10 || isTest || isXperia || isXperiaZ)
        {
         sessionStorage.rm_disablesound = 1; 
        }
      }

      



That code was written not by me and i can't explain it throughly.
You do not have the required permissions to view the files attached to this post.
Image
B
11
S
4
Posts: 13
Reputation: 803


Return to How do I....?

Who is online

Users browsing this forum: Jazz813, OddConfection, TRMG and 12 guests