Hi,
I have theis code which displays a movie from a url , but it doesnt play any sound. I have tried 2 approached but doesn’t like it for some reason…
I have tried [RequiredComponent (typeof (AudioSource))] but didnt seem to want to work.
I then tried adding an instance of AudioSource AS; in to the code but not working doesn’t throw any issues just doesnt play the sound. this is the code:
using UnityEngine;
using System.Collections;
using System;
//[RequireComponent (typeof(AudioSource))]
public class PlayMovie : MonoBehaviour {
public MovieTexture movieTwo;
public string url = “http://www.mindfulness-health.co.uk/test/one.ogv”;
public WWW www;
public AudioSource AS;
IEnumerator Start () {
//
movieTwo = new MovieTexture();
www = new WWW(url);
yield return www;
movieTwo = www.movie;
//
GetComponent().material.mainTexture = movieTwo;
movieTwo.Play();
//
AS = new AudioSource();
AS.clip = movieTwo.audioClip;
AS.volume = 1f;
AS.Play();
}
}