1, unity3d 5.0 dynamic play Video
Tools: Mobile Movie texture.unitypackage2.1.1
Problem Description: Currently this third-party playback video tool does not provide music playback, and the online textbook is to drag the video directly. Cannot dynamically change the video that needs to be played
Workaround:
Core code: m_movietexture.path = "MOVIESAMPLES/HANDOFFATE.OGV";
Sample Demo:
[Requirecomponent (typeof (MMT). Mobilemovietexture)]
public class Testmobiletexture:monobehaviour
{
Private MMT. Mobilemovietexture m_movietexture;
void Awake ()
{
m_movietexture = getcomponent<mmt. Mobilemovietexture> ();
//
m_movietexture.onfinished + = onfinished;
}
void Onfinished (MMT. Mobilemovietexture sender)
{
Debug.Log (sender. Path + "has finished");
}
private void Ongui ()
{
Guilayout.beginarea (New Rect (0.0f, 0.0f, Screen.width, screen.height));
var currentposition = (float) m_movietexture.playposition;
var newposition = Guilayout.horizontalslider (currentposition,0.0f, (float) m_movietexture.duration);
if (newposition! = currentposition)
{
M_movietexture.playposition = newposition;
}
Guilayout.flexiblespace ();
Guilayout.beginhorizontal ();
if (Guilayout.button (m_movietexture.isplaying? "Pause": "Play"))
{
if (m_movietexture.isplaying)
{
M_movietexture.pause = true;
}
Else
{
if (!m_movietexture.pause)
{
M_movietexture.path = "MOVIESAMPLES/HANDOFFATE.OGV";
M_movietexture.play ();
}
Else
{
M_movietexture.pause = false;
}
}
}
if (Guilayout.button ("Stop"))
{
M_movietexture.stop ();
}
Guilayout.endhorizontal ();
Guilayout.endarea ();
}
}
2, Unity3d 5.0 dynamic play Music
Tools: Mobile Movie texture.unitypackage2.1.1
Problem Description: Regular drag audio to engineering, unrecognized; At present, this online textbook is to drag audio directly to. Cannot dynamically change the video that needs to be played
Workaround: Unable to recognize the audio, you need to create a resource folder in the project root directory; dynamic playback with program code control
Core code:
Sample Demo:
Public Audiosource Soundsource;
Soundsource = getcomponent<audiosource> ();
Soundsource.clip = (audioclip) resources.load ("Love", typeof (AudioClip));//Call the resources method to load the AudioClip resource
Soundsource.play ();
Unity3d 5.0 Dynamic play video, play music