This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
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: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.

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 int 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);

                // passing node ownership to  the Editor
                GUIobject.release();
                Editor.get().addNode(GUIobject.getNode());

                // setting transformation and other parameters of the GUI object
                GUIobject.setWorldTransform(new Mat4(MathLib.translate(-0.5f, 1.0f, 1.5f) * MathLib.rotateX(90.0f)));
                GUIobject.setMaterial("gui_base", "*");
                GUIobject.setProperty("surface_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);
                TVscreen.release();

                // adding the sprite video widge to the GUI object
                GUIobject.getGui().addChild(TVscreen.getWidget(), Gui.ALIGN_OVERLAP | Gui.ALIGN_BACKGROUND);

                // setting looped playback mode
                TVscreen.setLoop(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);
                MAINscreen.release();

                // setting size and position of the second sprite video widget on the screen
                MAINscreen.setPosition(100, 100);
                MAINscreen.setWidth(400);
                MAINscreen.setHeight(225);
                MAINscreen.arrange();

                // adding the sprite video widge to the system GUI
                Gui.get().addChild(MAINscreen.getWidget(), Gui.ALIGN_OVERLAP | Gui.ALIGN_BACKGROUND);

                // setting looped playback mode
                MAINscreen.setLoop(1);

                // launching playback
                MAINscreen.play();

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

WidgetSpriteVideo Class

Members


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

Constructor. Creates a new sprite that plays video.

Arguments

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

WidgetSpriteVideo cast(Widget widget)

Casts a WidgetSpriteVideo out of the Widget instance.

Arguments

  • Widget widget - Widget instance.

Return value

WidgetSpriteVideo instance.

void setAmbientSource(AmbientSource source)

Synchronizes video playback to the ambient sound source playback.

Arguments

  • AmbientSource source - Ambient sound source according to which video playback will be synchronized.

AmbientSource getAmbientSource()

Returns the ambient sound source according to which video playback is synchronized.

Return value

Ambient sound source.

void setLoop(int loop)

Sets a value indicating if the video should be looped.

Arguments

  • int loop - Positive number to loop the video, 0 to play it only once.

int getLoop()

Returns a value indicating if the video is looped.

Return value

Positive number if the video is looped; otherwise, 0.

int isPlaying()

Returns a value indicating if the video is being played at the moment.

Return value

1 if the video is being played; otherwise, 0.

void setSoundSource(SoundSource source)

Synchronizes video playback to the sound source playback.

Arguments

  • SoundSource source - Sound source according to which video playback will be synchronized.

SoundSource getSoundSource()

Returns the sound source according to which video playback is synchronized.

Return value

Sound source.

int isStopped()

Returns a value indicating if the video is stopped at the moment.

Return value

1 if the video is stopped; otherwise, 0.

void setVideoTime(float time)

Rewinds or fast-forwards the video to a given time.

Arguments

  • float time - Time in seconds.

float getVideoTime()

Returns the time of the currently played frame.

Return value

Time in seconds.

void setYUV(int yuv)

Sets a flag for YUV conversion.

Arguments

  • int yuv - Mode flag: 1 if convertion to RGB should be performed by the GPU, 0 if it is converted by the CPU.

int getYUV()

Returns a flag for YUV conversion.

Return value

1 if convertion to RGB is performed by the GPU, 0 if it is converted 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: 2018-08-10
Build: ()