Version: 2018.1 (switch to 2018.2b or 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Removed in version 2018.1.3

WWW.movie

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete public var movie: Object;
Obsolete public Object movie;

Description

Returns a MovieTexture generated from the downloaded data (Read Only).

The data must be a movie in Ogg Theora format.

Even if the movie is not yet completely downloaded, this returns immediately, allowing you to start playing the partial movie as it downloads.

See Also: MovieTexture.audioClip.

var url = "http://www.unity3d.com/Movie/sample.ogg";

function Start () { // Start download var www = new WWW(url); yield www;

// Make sure the movie is ready to start before we start playing var movieTexture = www.GetMovieTexture(); while (!movieTexture.isReadyToPlay) yield;

var gt = GetComponent.<GUITexture>();

// Initialize gui texture to be 1:1 resolution centered on screen gt.texture = movieTexture;

transform.localScale = Vector3 (0,0,0); transform.position = Vector3 (0.5,0.5,0); gt.pixelInset.xMin = -movieTexture.width / 2; gt.pixelInset.xMax = movieTexture.width / 2; gt.pixelInset.yMin = -movieTexture.height / 2; gt.pixelInset.yMax = movieTexture.height / 2;

// Assign clip to audio source // Sync playback with audio var aud = GetComponent.<AudioSource>(); aud.clip = movieTexture.audioClip;

// Play both movie & sound movieTexture.Play(); aud.Play(); } // Make sure we have gui texture and audio source @script RequireComponent (GUITexture) @script RequireComponent (AudioSource)
using UnityEngine;
using System.Collections;

// Make sure we have gui texture and audio source [RequireComponent(typeof(GUITexture))] [RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { string url = "http://www.unity3d.com/Movie/sample.ogg";

IEnumerator Start() { // Start download using (var www = new WWW(url)) { yield return www;

// Make sure the movie is ready to start before we start playing var movieTexture = www.GetMovieTexture(); while (!movieTexture.isReadyToPlay) yield return null;

var gt = GetComponent<GUITexture>();

// Initialize gui texture to be 1:1 resolution centered on screen gt.texture = movieTexture;

transform.localScale = new Vector3(0, 0, 0); transform.position = new Vector3(0.5f, 0.5f, 0.0f); var pixelInset = gt.pixelInset; pixelInset.xMin = -movieTexture.width / 2; pixelInset.xMax = movieTexture.width / 2; pixelInset.yMin = -movieTexture.height / 2; pixelInset.yMax = movieTexture.height / 2; gt.pixelInset = pixelInset;

// Assign clip to audio source // Sync playback with audio var aud = GetComponent<AudioSource>(); aud.clip = movieTexture.audioClip;

// Play both movie & sound movieTexture.Play(); aud.Play(); } } }

Did you find this page useful? Please give it a rating: