Handheld.PlayFullScreenMovie issue

I have my intro mp4 file ("intro.mp4") in StreamingAssets folder and it works great on iphone/ipad, but not work on Windows phone. I tried to change codecs but even with guidlines codec and settings it doesn't work. Game launches, after Unity splashscreen it should play intro movie and then load to main menu.

function Start() {

Handheld.PlayFullScreenMovie ("intro.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
Applictaion.LoadLevel("menu");

}

now after launch it shows Unity splash screen and then it loads into main menu without playing the intro movie.

Codec setings (H.264 Baseline Profile, up to 800 x 480 at 30 fps. No B frames.) Unity can play it in editor import settings (right bottom corner)

You need to use http://docs.unity3d.com/Documentation/Manual/VideoFiles.html MovieTexture instead.

Ok, but how can I build if pop up error shows BCE0018: The name 'MovieTexture' does not denote a valid type ('not found').

in editor it works great, but can't build for WindowsPhone.

here is the code:
var movTexture : MovieTexture;

function Start () {

movTexture = renderer.material.mainTexture;

if (movTexture.isPlaying) {

movTexture.Stop();
audio.Stop();

} else {

movTexture.Play();
audio.Play();

}

}

function Update () {

if (Input.GetMouseButtonDown(0)) {

audio.Stop();
movTexture.Stop();
Application.LoadLevel("menu");

}

}

I'm afraid MovieTexture is not supported on Windows Phone 8 - sorry for the confusion.

There is another way to play videos - that is through Media Element in XAML. You can write that code in the generated Visual Studio solution. It should be pretty straightforward: just add MediaElement to MainPage.xaml file inside of DrawingSurfaceBackground:

    <DrawingSurfaceBackgroundGrid x:Name="DrawingSurfaceBackground" Loaded="DrawingSurfaceBackground_Loaded">
        <MediaElement x:Name="VideoPlayer" Source="Assets/intro.mp4" AutoPlay="True" MediaEnded="OnMediaEnded" />
    </DrawingSurfaceBackgroundGrid>

Then, add OnMediaEnded method to MainPage.xaml.cs, which will hide the media player after video is done playing:

        private void OnMediaEnded(object sender, RoutedEventArgs e)
        {
            DrawingSurfaceBackground.Children.Remove(VideoPlayer);
        }

Hello,

We are doing this exact thing for the movies. However it appears that it i add an action on "tapped" to stop the movie and remove the component before the movie actually ends i get graphics errors from Unity. Has anyone had any success using this method and stopping the movie early?

graphic errors include (varied from execution to execution)
1. last shown frame of movie ghosting over unity window
2. Unity acting like my cameras having a clear flag of none.

1 Like

I'm confused slightly as this is really simple example.

I currently have buttons in the game when the player clicks will play a video, currently had to comment them out in mono develop. So you saying should not edit the mono script but build project first then edit in visual studio?

It's been a long time since I wrote that :).

Either way, yes, the code I wrote is supposed to go to MainPage.xaml and MainPage.xaml.cs files. Of course, you could also setup callbacks to your scripts, and invoke the video playback from them.

Yes long time :-) , thing is I think many people start making a game with the knowledge of Unity manual which mentions to use Handheld.PlayFullScreenMovie and it does not say anything about it not working in Windows Phone 8.1 etc I made this mistake also. Now after all the other platforms released I realize I need to change for Win Phone 8.1 and no plugins on the asset store either.

But I;m asking is there a way within Unity3d/mono to code in c sharp and not do any editing in Visual Studio.

Thank you

Well, you could write a plugin yourself, or wrap your scripts that do it in #if NETFX_CORE/#endif.