Sign In Register

How can we help you today?

Start a new topic
Answered

Problem with url parameters for downloadables

I'm trying to set up .ogg audio file streaming with unity and encountered the following problem; the download url returned by GameSparksApi.getDownloadableRequest is something like this (some id's scrambled):

http://gamesparksbetabinaries.blob.core.windows.net/game-123456/123456789-Dj%20Tabora%20-%20Dashboard%20Baby.ogg?sp=r&sr=b&sv=2012-02-12&se=2014-05-27T19%3A30%3A32Z&st=2014-05-12345678&sig=12345678


The url parameters confuse UnityEngine.WWW:GetAudioClip so that it fails to detect audio format:

Unable to determine the audio type from the URL (<see above>) . Please specify the type.

UnityEngine.WWW:GetAudioClip(Boolean, Boolean)


Any ideas how to resolve this? Would it be possible to embed the url parameters with slashes, eg. http://www.domain.com/param1/param2/param3/filename.ogg? This is hardly worth the trouble for this particular case but this same problem could emerge elsewhere as well. Ideally this should be fixed in unity so that it would omit the url parameters but you can't expect them to do anything about it.


Best Answer

Hi Jussi


Thanks for the code, it seem we had a missing crossdomain.xml on the blob storage that is required for you to use the WWW class in the unity editor.


You code is now working for me, and you'll not have the issue again.


Gabriel




Hi Jussi


I've just looked through the source for the WWW class, and GetAudioClip is overloaded. There is a version with 3 parameters where you can pass in the type of the audio as AudioType.OGGVORBIS.


If this doesn't work for you, could you share some code?


Thanks


Gabriel

Oops didn't notice that overload - thanks for pointing this out. However I'm now getting an empty download (size is 0 bytes) with the same code that yesterday downloaded the files from GS. Are you making some updates on the blob server? Tried uploading a new file to downloadables but also that one is returning an empty file. File sizes are however listed correctly on the Downloadable Content page.

 

public class RemoteAudioController : BinderBase
{
	public override void Initialize()
	{
		base.Initialize();
		LoginController.UserAuthenticated += UserAuthenticated;
	}

	private void UserAuthenticated()
	{
		GameSparksSender sender = GameSparksApi.getDownloadableRequest("IceFlow");
		sender.sendAsync(LoadedCallback);
	}

	private void LoadedCallback(IDictionary<string, object> response)
	{
		string url = response["url"] as string;
		StartCoroutine(BeginLoadAudio(url));
	}
	public AudioSource Player;

	private IEnumerator BeginLoadAudio(string url)
	{
		WWW audioLoader = new WWW(url);
		while (!audioLoader.isDone && audioLoader.progress < 0.1f)
		{
			DebugUtility.LogDebug("Loading progress " + audioLoader.progress);
			yield return new WaitForSeconds(0.5f);
		}

		DebugUtility.LogDebug("Starting playback, size " + audioLoader.bytesDownloaded);
		Player.clip = audioLoader.GetAudioClip(false, true, AudioType.OGGVORBIS);
		Player.Play();
		Player.volume = 1;
	}
}

   



Answer

Hi Jussi


Thanks for the code, it seem we had a missing crossdomain.xml on the blob storage that is required for you to use the WWW class in the unity editor.


You code is now working for me, and you'll not have the issue again.


Gabriel



Confirmed that the downloads work now. Thanks for your support with my silly RTFM issue :D

Login to post a comment