Mark Jackson
Mark Jackson

Reputation: 85

Play video in Unity 5.5 Personal edition

I looked at the MovieTexture class, to play videos from Unity's C# scripting, but MovieTexture is for Unity Pro, and I don't have the Pro version.

I also looked at PlayFullScreenMovie, to play videos, but that works only if I import the video as an asset inside Unity's Project folder.

My question is: Is there a way to play a video in Unity Personal edition, without importing the video as an asset? Like, can I use the video's file location (filepath) in the computer as the source url to play the video from? Thanks.

Upvotes: 1

Views: 1407

Answers (1)

Programmer
Programmer

Reputation: 125275

I looked at the MovieTexture class to play videos from Unity's C# scripting but MovieTexture is for Unity Pro and I don't have the Pro version

Not true. After Unity 5.0 release, pro only API and tools in Unity became available in all version of Unity. You can use MovieTexture in Unity 5.5.

I also looked at PlayFullScreenMovie to play videos but that works only if I import the video as an asset inside Unity's Project folder

If your goal is to play video from the internet, url, local network or folder, forget about PlayFullScreenMovie. It's not made for that.

Like can I use the video's file location (filepath) in the computer as the source url to play the video from?

You can do this with MovieTexture. Note that there is a big limitation with MovieTexture. For example, I've never seen it play .mp4 video before. It plays .ogg movie. Since you don't want to use Unity 5.6, you are very limited to things you can do with MovieTexture. It can't play video on mobile devices.

MovieTexture movieTexture;
AudioSource vidAudio;
public RawImage rawImage;

void Start()
{
    WWW www = new WWW("http://techslides.com/demos/sample-videos/small.ogv");
    movieTexture = www.GetMovieTexture();
    rawImage.texture = movieTexture;

    vidAudio = gameObject.AddComponent<AudioSource>();
    vidAudio.clip = movieTexture.audioClip;
}

void Update()
{
    if (movieTexture.isReadyToPlay && !movieTexture.isPlaying)
    {
        movieTexture.Play();
        vidAudio.Play();
    }

    if (movieTexture.isPlaying)
    {
        rawImage.texture = movieTexture;
    }
}

That remaining option left is to buy a video plugin or make one. These are very expensive so here are the top working ones. AVPro Video and Easy Movie Texture.

Upvotes: 2

Related Questions