Search Unity

WebGL Audio is not working in iOS ?

Discussion in 'Audio & Video' started by nishimoto_t, Jul 28, 2016.

  1. nishimoto_t

    nishimoto_t

    Joined:
    Feb 4, 2016
    Posts:
    2
    I'm making AudioTestProject for WebGL.
    In project, I confirmed whether audio works on each platform.

    The case of PC, Android, Audio worked normally.
    But case of iOS(iPhone5s), Audio didn't work(not hear anything).
    The Blowser I confirmed is Safari, Chrome, and Firefox.
    And, The file format of audio clip is mp3, wav, and ogg.

    Do you know anything about this problem ?
     
  2. ScottYann

    ScottYann

    Joined:
    Jun 14, 2013
    Posts:
    12
    I found a solution finally! I spent 8 hours on this on a Sunday and I just figured it out by accident. There is simply no way to play back Unity audio in iOS Safari normally. It won't work on chrome for iOS either. I thought it could be audio formats or the dreaded user interaction "feature" which only allows audio playback with a user interaction. I tried tweaking all of that and nothing worked. The only solution is to install your unity WebGL web page project as a web app. To do that you will need the following two tags in your HTML template header file:

    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="mobile-web-app-capable" content="yes">

    you may also want to use this tag to get an icon for your web app (it sometimes works, other times doesn't but it can be better than nothing)
    <link rel="apple-touch-icon" href="/custom_icon.png">

    To install your web page as a web app what you need to do is navigate to your web page in safari then press the button in safari that looks like a box with an arrow pointing up (this is the share icon). Then select "add to home screen". Quit safari then run your app from the home screen. Boom! All audio now works!

    PS never use the default memory size that Unity gives you for WebGL, it will relentlessly crash the player on a 1 Gig iPhone. You will want to keep your memory size 150 megs or below. 256 megs is just way too much. It doesn't offer any clues when it reloads the page. The lack of clues is really a clue in itself because the debugger exits when it panics and runs out of memory.
     
    Last edited: Feb 27, 2017
    natsupy likes this.
  3. natsupy

    natsupy

    Joined:
    Feb 5, 2016
    Posts:
    17
    hi, i'm have same issue with audio on webgl, following you after build file to webgl, i add tag as you, but seem cant add web app on safari, so what am i mistake, can you help!
     
    Last edited: May 20, 2017
  4. ScottYann

    ScottYann

    Joined:
    Jun 14, 2013
    Posts:
    12
    Hi Nat supy,

    Try the share button in safari for ios, its the thing with the box and the arrow pointed up. Click on it after you've navigated to your web page and then select add to home screen
     
  5. natsupy

    natsupy

    Joined:
    Feb 5, 2016
    Posts:
    17
    uhm, so can you try on my page, i uploaded on github, or it may be not support !?
    https://natsupy.github.io/
     
  6. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    163