This script is hung under plane to hang the audio sourse and audio listener components on this object to play the video properly. These two components hang on the camera and cannot play the video.
Using Unityengine;
Using System.Collections;
public class Testmp4b:monobehaviour {
Movie Textures
Public Movietexture mov;
void Start ()
{
Audio.clip = Mov.audioclip;
Audio. Play ();
mov. Play ();
Set the movie texture playback mode to loop
Mov.loop = true;
}
void Ongui ()
{
if (GUI. button (new Rect (310,0,100,50), "twice Times Playback"))
{
Audio.pitch = 2f;
}
if (GUI. button (new Rect (410,0,100,50), "1 time Times Playback"))
{
Audio.pitch = 1f;
}
Gui. Drawtexture (New Rect (0,0,300,300), MOV);
Draw a movie texture
Gui. Drawtexture (New Rect (0, 0, Screen.width, screen.height), MOV, Scalemode.stretchtofill);
if (Guilayout.button ("Play/Continue"))
{
Play/Resume Video
if (!mov.isplaying)
{
mov. Play ();
}
}
if (Guilayout.button ("Pause playback"))
{
Pause Playback
mov. Pause ();
}
if (Guilayout.button ("Stop playing"))
{
Stop playing
mov. Stop ();
}
}
}
MP4 Play on Drawtexture