- Home /
Infinitely repeating sound when minimizing web player
Hello all. I have come across a rather strange occurrence that I have been able to find nothing on. When I run my game in a web player, if I minimize that web player and bring it back up, I get a sound that repeats throughout the rest of my scene. It is just a dun dun dun dun dun dun over and over and over again. It appears to be caused by the following script, but I have no idea why. Any suggestions?
using UnityEngine;
using System.Collections;
public class FinalMovieScript : MonoBehaviour {
public MovieTexture movieClip;
public GameObject movieTexture;
public AudioClip audioSound;
int movieCount = 0;
void Start()
{
movieTexture.active = false;
}
void OnMouseDown()
{
if(movieCount < 1)
{
movieTexture.active = true;
movieTexture.renderer.material.mainTexture = movieClip;
movieClip.Play();
audio.Play();
movieCount++;
}
}
void Update()
{
if(movieClip.isPlaying)
{
GameManager.popQuestion = false;
}
else
{
movieTexture.active = false;
GameManager.popQuestion = true;
}
}
}
Nothing? Come on, don't let me down guys :P This is truly an annoying problem. While it isn't game breaking, it is something I would like to figure out so I know how to avoid it in the future. Any suggestions?
Answer by alishka · Jan 26, 2016 at 08:59 AM
Add an OnApplicationPause() {...}
event handler where you silence audio by code. Make sure you turn it back on when you're back to the game.
Cheers!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I implement a third party API into Unity 3D? For Flash. 0 Answers
How to optimize the build game for unity webplayer? 1 Answer
Play Audio Through Scenes 0 Answers