This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
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
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

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: 2024-04-19
Build: ()