How to Control Video Playback with PolySpatialVideoComponent

Hi,

I’m using Unity’s video player in my application and trying to adapt it to AVP. If I understand correctly, only the use of the Polyspatial Video component allows playing videos, and it works only in mixed reality. How can I control the playback and pause of a video with this component? I can’t seem to find any documentation that presents the methods that can be called with this script.

I have this error:
error CS0246: The type or namespace name ‘PolySpatialVideoComponent’ could not be found (are you missing a using directive or an assembly reference?)

Thanks!

1 Like

The Unity.PolySpatial.PolySpatialVideoComponent class has methods Start(), Play(), Stop(), and Pause() that allow control of playback.

How are you attempting to create the component? Typically one would add an instance of it to a GameObject via the Inspector. If you’re creating it in code, you may need a “using Unity.PolySpatial;” directive at the top of the file.

Thanks @kapolka,

I managed to integrate my video; I didn’t understand how to add the directive at first.

Is there a way to programmatically modify the Video Clip of the component currently?

I’m trying to change the value of m_Clip, but it doesn’t seem to be accessible.

public void LoadVideo(int index)
{
    VideoPlayer.m_Clip = VideoClips[index];
}

Error CS1061: ‘PolySpatialVideoComponent’ does not contain a definition for ‘m_Clip,’ and no accessible extension method ‘m_Clip’ accepting a first argument of type ‘PolySpatialVideoComponent’ could be found (are you missing a using directive or an assembly reference?)

The public property is just called clip, so it should be:

VideoPlayer.clip = VideoClips[index];

There’s also a targetMaterialRenderer property that needs to be set to the MeshRenderer to apply the video material to.

1 Like

Is there a way to get Play Seek of clip ?

I’m facing a bug that I can’t seem to understand.

I have an animation in the form of a video that I need to play multiple times. So, I use Play() to start it and Stop() after a delay that corresponds to the duration of my video, then I call Play() again to start it a second time, and so on.

My video plays several times as expected in the Unity Editor via PolySpatialVideoComponent, as described in my code.

However, when I test in the simulator, the video only plays once and nothing is displayed after that.

PS: I also noticed that Start() doesn’t seem to work.

Not at the moment, no. We are working on support for Unity’s VideoPlayer component, which will provide more control.

1 Like

If you submit a bug report with a repro case and let us know the incident number (IN-#####), that will help us investigate the issue. @vcheung-unity in particular may have some insight.

As @kapolka mentioned, a repro project would be great!

Some additional questions to look into - is this video component set to looping or non-looping? If you set it to looping, does that fix the issue?

And can I get some details on the issue with PolySpatialVideoComponent::Start()? Is it not playing the video when you disable and re-enable the video component with PlayOnAwake set to true?

Ok, I’m going to try to do a repro project in the next few days.

Here are some details I can provide right now.

Initially, my Polyspatial video component was non-looping. I set it to loop for testing, and it loops correctly. However, it doesn’t seem to respond to my Stop() and then Play() calls, which I would like to use to restart the video from the beginning.

Regarding Start(), when I try to use it, I get this error:
error CS1061: ‘PolySpatialVideoComponent’ does not contain a definition for ‘Start’ and no accessible extension method ‘Start’ accepting a first argument of type ‘PolySpatialVideoComponent’ could be found (are you missing a using directive or an assembly reference?)

Sorry, I shouldn’t have listed Start along with the other methods. Start is a private method that runs on startup (just the standard MonoBehaviour.Start method). The method to use to start the video is Play (and you should be able to control whether the video plays on startup with the playOnAwake field).