Playing Full Screen Video on Windows 8.1 Phone Store App

Hi, I have a working app I’m porting from Droid to Windows Phone 8.1. It’s not my app, and I’m not terribly familiar with Unity but I’m learning as I go. So far I’ve got almost all of it working and running on a device, however video files don’t play.

Currently there is a script that looks like this:

using UnityEngine;
using System.Collections;

public class PlayVideo : MonoBehaviour
{
    public string path;
    [ContextMenu ("Play")]
    public void Play()
    {
        Handheld.PlayFullScreenMovie (path);
    }
}

I noticed in the docs there was a small comment regarding this:

It says Internally, so I’m assuming, probably incorrectly, that I don’t have to mess with XAML?

I’ve also created the StreamingAssets folder under Assets and dropped my video in there.

Interesting point: I changed the path of my movie to StreamingAssets/video.mp4 and I got an exception, so it appears it’s doing something, at the very least it finds the file otherwise I’m guessing it would throw an exception when I just give it video.mp4

My gut feeling is I’m missing some kind of Visual Studio side markup in the XAML, maybe…

I’ll continue trying to trace through the scripts and see what falls out, but if anyone has any tips or tricks re Video on Windows Phone 8.1 / Windows Store apps then I’d be very happy to see them, thanks!

I am guessing you’re incorrectly forming the path, it should be something like:

Path.Combine(Application.streamingAssetsPath, "video.mp4");
1 Like

Thanks Tomas!

That works a treat!

Do you know how I can stop and remove the video player on the windows back button? We failed submission on this :frowning: I added CancelOnInput which works for a screen press but not for the hardware back button. I’m thinking that maybe we can override the back button to be something else at runtime just before the video play and put it back after, but not sure how.

if this still holds true, it (the back button) fires the escape key event… you could detect that, fire an event or callback to stop the video…et al.

Unfortunately that doesn’t work, the video effectively pauses unity by their design, so no other code executes.

if that’s the case, perhaps a workaround would be to play the video on the XAML/C# (UI thread) and use callbacks into Unity for pause, exit, etc…?

Thanks, That’s interesting, can you give me a few pointers or a link with info on how to do that?

there is a XAML to Unity example here: http://docs.unity3d.com/Manual/windowsstore-examples.html

and something here for phone: http://docs.unity3d.com/Manual/wp8-unity-interaction.html

I’m almost certain they have some specific code examples you can download, just not sure where they are atm…

1 Like

here they are: http://docs.unity3d.com/Manual/wp8-examples.html

1 Like

Thanks again!

Hopefully that works with Windows Phone 8.1, only one way to find out :wink:

I don’t think those samples will work on 8.1, not without some substantial tinkering

maybe a moderator could move this thread over to the Windows Platform forum area… i’m sure there’s someone there that probably knows what exactly to do…