This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Режимы вывода изображения
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
API Samples
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
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
Учебные материалы

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: 13.12.2024
Build: ()