- Home /
Question by
stevenmc_sf · Oct 08, 2019 at 06:00 PM ·
c#scripting problemwebgl
WebGL audio and Slider Interaction
First, I am a total newbie. Second, I am trying to get an audio file position in time to be controlled by a slider UI element. When previewing locally everything works fine. When publishing to WebGL and viewing online I am experiencing substantial audio crackling. I have traced it to the last line of the below code which is commented out. Can anyone recommend a better way to link the slider value and audio time? Is it that it is being constantly updated?
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class demo : MonoBehaviour
{ AudioSource audios; Slider slider; public AudioClip song;
void Start()
{
audios = GetComponent<AudioSource>();
slider = GetComponent<Slider>();
audios.clip = song;
audios.Stop();
slider.minValue = 0;
slider.maxValue = song.length;
}
void Update()
{
slider.value = audios.time;
}
/*
public void MovePosition()
{
audios.time = slider.value;
}
*/
}
Comment