Down below you have solution.
First problem was fixed by adding ‘if… else’ in ‘Awake()’ method.
Second problem was fixed by changing:
// Audio source.
private AudioSource audio_source;
To:
// Audio source.
private static AudioSource audio_source;
Second problem was becouse on entire loop of scenes, when first scene(start scene) is loaded second time, method ‘OnLevelWasLoaded()’ can be run from new instance of ‘MusciPlayer’.
Hope this will help you. For me it solved the problem.
Solution
Alternative you can change ‘OnLevelWasLoaded’ to this:
// Event - when level was loaded.
public void OnLevelWasLoaded(int level)
{
// If there is instance of game music and it is not this one.
if((instance!=null)&&(instance!=this))
{
// Exit from function
return;
}
// rest of the function
// …
} // End of OnLevelWasLoaded
Personally i think that should be putted in the subtitles of the video.