This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm (Experimental)
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.WidgetSpriteVideo Class

Inherits: 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.

You can copy the code below and paste it to the AppWorldLogic.cs source file of your project (implementation of all other methods except for the Init() should be left as is):

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

using Unigine;

#if UNIGINE_DOUBLE
using Mat4 = Unigine.dmat4;
#else
    using Mat4 = Unigine.mat4;
#endif
namespace UnigineApp
{
	class AppWorldLogic : WorldLogic
	{
		// World logic, it takes effect only when the world is loaded.
		// These methods are called right after corresponding world script's (UnigineScript) methods.

        // path to the video file to play (only *.OGV type is supported)
        String file_name = "<YOUR_VIDEO_FILE_NAME>.ogv";

        // Define the GUIobject and WidgetSpriteVideo instances
        // so that they are deleted with the AppWorldLogic instance
        ObjectGui GUIobject;

        // sprite video widgets
        WidgetSpriteVideo TVscreen;
        WidgetSpriteVideo MAINscreen;

		/* .. */

		public override bool Init()
		{
			// Write here code to be called on world initialization: initialize resources for your world scene during the world start.


                // creating a GUI object with the following size: 1.0f x 0.5f 
                GUIobject = new ObjectGui(1.0f, 0.5f);

                // setting transformation and other parameters of the GUI object
                GUIobject.WorldTransform = new Mat4(MathLib.Translate(-0.5f, 1.0f, 1.5f) * MathLib.RotateX(90.0f));
                GUIobject.SetMaterial("gui_base", "*");
                GUIobject.SetMaterialState("mode", 1, 0);


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

                // adding the sprite video widge 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();

                // creating the second sprite video widget that plays a file_name video file on the system GUI
                MAINscreen = new WidgetSpriteVideo(Gui.Get(), 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.Get().AddChild(MAINscreen, Gui.ALIGN_OVERLAP | Gui.ALIGN_BACKGROUND);

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

                // launching playback
                MAINscreen.play();

			return 1;
		}
		
		/* .. */
	}
}

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#

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

bool IsPlaying#

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

AmbientSource AmbientSource#

The ambient sound source according to which video playback is synchronized.
set
Synchronizes video playback to the ambient sound source playback.
set value - Ambient sound source according to which video playback will be synchronized.

SoundSource SoundSource#

The sound source according to which video playback is synchronized.
set
Synchronizes video playback to the sound source playback.
set value - Sound source according to which video playback will be synchronized.

float VideoTime#

The time of the currently played frame.
set
Rewinds or fast-forwards the video to a given time.
set value - Time in seconds.

int YUV#

A flag for yuv conversion.
set
Sets a flag for YUV conversion.
set value - Mode flag: 1 if conversion to RGB should be performed by the GPU, 0 if it is converted by the CPU.

int Loop#

A value indicating if the video is looped.
set
Sets a value indicating if the video should be looped.
set value - Positive number to loop the video, 0 to play it only once.

Members


static 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.

static 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: 2020-11-24
Build: ()