Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by deltron1830 · Apr 16, 2018 at 09:44 AM · audiowebglloop

Unity WebGL audio not looping when started with playdelayed()

I have an audioSource in which loop is set to true. I am starting it playing by calling playdelayed()

In the editor its plays fine. In a webgl build it does not loop. It just plays once.

Also in firefox it does not start playing at the correct time, it is a good fraction of a second off.

 public override void MatchStarted()
 {
     Intro.Play();
     Loop.PlayDelayed(Intro.clip.length);
 }


PlayScheduled has exactly the same effect.

 public override void MatchStarted()
 {
     Intro.Play();
     Loop.PlayScheduled(AudioSettings.dspTime + Intro.clip.length);
 }

Play(ulong) has the same effect

 public override void MatchStarted()
 {
     Intro.Play();
     Loop.Play((ulong)(44100 * Intro.clip.length));
 }

I'm posting this here seeking workarounds. Any suggestions? As you can see from my code, my use case is a piece of music with an intro and a loop.

...

ps. I have seen some posts saying that if the bitrate is not 44.1 KHz this can cause looping issues on WebGl. The audio file in question is set to override the bitrate to 44.1 in its import settings.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by deltron1830 · Apr 16, 2018 at 01:32 PM

Ok here is my workaround. I added the intro and loop together into one file. I also added on a little bit more of the start of the loop onto the end, and I made a note of exactly what time the loop should start and end at.

alt text

 const float startlooptime = 11.875f;
 const float endlooptime = 74.375f;
 
 public override void MatchStarted()
 {
     Loop.Play();
 }
 
 void Update()
 {
     if (!Loop.isPlaying) return;
 
     if (Loop.time > endlooptime) Loop.time = startlooptime + (Loop.time - endlooptime);
 }
 


Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fhamel · Oct 04, 2020 at 05:37 PM 0
Share

Cheers for this insight man! This issue is still around in 2020.1.6f1. I had the exact same use case and tests, almost down to the variable names, haha. Great idea - thanks for sharing!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Audio loop after time 2 Answers

How can I loop a song from a specific point? 1 Answer

[iOS] Streaming audio with loop 1 Answer

How can i make my audio loop faster/slower? 0 Answers

Audio lag/loop after weplayer gets focus again 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges