Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Handheld.PlayFullScreenMovie issue

Discussion in 'Windows' started by FIllbiker, Aug 17, 2013.

  1. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    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)
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
  3. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    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");


    }

    }
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    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:

    Code (csharp):
    1.  
    2.     <DrawingSurfaceBackgroundGrid x:Name="DrawingSurfaceBackground" Loaded="DrawingSurfaceBackground_Loaded">
    3.         <MediaElement x:Name="VideoPlayer" Source="Assets/intro.mp4" AutoPlay="True" MediaEnded="OnMediaEnded" />
    4.     </DrawingSurfaceBackgroundGrid>
    Then, add OnMediaEnded method to MainPage.xaml.cs, which will hide the media player after video is done playing:

    Code (csharp):
    1.  
    2.         private void OnMediaEnded(object sender, RoutedEventArgs e)
    3.         {
    4.             DrawingSurfaceBackground.Children.Remove(VideoPlayer);
    5.         }
     
  5. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    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.
     
    Last edited: Mar 17, 2014
    b4cksp4ce likes this.
  6. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712

    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?
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    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.
     
  8. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    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
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Well, you could write a plugin yourself, or wrap your scripts that do it in #if NETFX_CORE/#endif.