This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine.WidgetSpriteVideo Class

Inherits from: WidgetSprite

This class is used to create a virtual monitor that plays a video file (currently only *.OGV files are supported). It can be synchrozied with playback of the ambient sound or the directional sound source.

The following example illustrates how to play a video-file on the system GUI or a GUI object using the WidgetSpriteVideo class.

Create a new C# component named VideoSprite and copy the code below:

Source code (C#)
using System;
using System.Collections;
using System.Collections.Generic;
using Unigine;

[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class VideoSprite : Component
{
	// path to the video file to play (only *.OGV type is supported)
	[ParameterFile(Filter =(".ogv"))]
	public String file_name;

	// sprite video widgets
	WidgetSpriteVideo TVscreen;
	WidgetSpriteVideo MAINscreen;

	private void Init()
	{
		// creating the first sprite video widget that plays a file_name video file on the system GUI
		MAINscreen = new WidgetSpriteVideo(Gui.GetCurrent(), file_name, 1);

		// setting size and position of the second sprite video widget on the screen
		MAINscreen.SetPosition(100, 100);
		MAINscreen.Width = 400;
		MAINscreen.Height = 225;
		MAINscreen.Arrange();

		// adding the sprite video widge to the system GUI
		Gui.GetCurrent().AddChild(MAINscreen, Gui.ALIGN_OVERLAP | Gui.ALIGN_BACKGROUND);

		// setting looped playback mode
		MAINscreen.Loop = 1;

		// launching playback
		MAINscreen.Play();

		// checking if the node to which the component is assigned is a GUI Object
		if(node.Type != Node.TYPE.OBJECT_GUI)
		{
			Log.Message("Node is not a GUI Object!\n");
			return;
		}
		ObjectGui GUIObject = node as ObjectGui;

		// creating the second sprite video widget that plays a file_name video file on the GUI object
		TVscreen = new WidgetSpriteVideo(GUIObject.GetGui(), file_name, 1);

		// adjusting the size of the widget to fit the size of the GUI object
		TVscreen.Width = GUIObject.ScreenWidth;
		TVscreen.Height = GUIObject.ScreenHeight;

		// adding the sprite video widget to the GUI object
		GUIObject.GetGui().AddChild(TVscreen, Gui.ALIGN_OVERLAP | Gui.ALIGN_BACKGROUND);

		// setting looped playback mode
		TVscreen.Loop = 1;

		// launching playback
		TVscreen.Play();
	}
	
	private void Update()
	{
		// write here code to be called before updating each render frame
		
	}
}

See Also#

  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder:
    • video_00
    • video_01

WidgetSpriteVideo Class

Properties

bool IsStopped#

The value indicating if the video is stopped at the moment.

bool IsPlaying#

The value indicating if the video is being played at the moment.

AmbientSource AmbientSource#

The ambient sound source according to which video playback is synchronized.

SoundSource SoundSource#

The sound source according to which video playback is synchronized.

float VideoTime#

The time of the currently played frame.

int YUV#

The flag for yuv conversion.

int Loop#

The value indicating if the video is looped.

Members


WidgetSpriteVideo ( Gui gui, string name = 0, int mode = 1 ) #

Constructor. Creates a new sprite that plays video and adds it to the specified GUI.

Arguments

  • Gui gui - GUI, to which the new sprite will belong.
  • string name - Path to a video file.
  • int mode - YUV flag: 1 if conversion to RGB should be performed by the GPU, 0 - if by the CPU.

WidgetSpriteVideo ( string name = 0, int mode = 1 ) #

Constructor. Creates a new sprite that plays video and adds it to the Engine GUI.

Arguments

  • string name - Path to a video file.
  • int mode - YUV flag: 1 if conversion to RGB should be performed by the GPU, 0 - if by the CPU.

void Play ( ) #

Starts playing video.

void Stop ( ) #

Stops playing video. This function saves the playback position so that playing of the file can be resumed from the same point.
Last update: 2023-01-13
Build: ()