Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
VideoElement
DescriptionPlays back a video.Parent
GuiElementXML Configuration Parameters
GuiElement#videoFileName | string File path to video file. If the path contains the special string "$l10nSuffix", it will be substituted by the current language code to allow automatically selecting the proper language video in the file system. |
GuiElement#volume | float [optional] Playback volume, defaults to 1 (maximum). |
GuiElement#allowStop | bool [optional] If false, does not allow skipping the video by mouse click. Keyboard inputs will always skip the video. |
GuiElement#isLooping | bool [optional] If true, the video is restarted when playback is finished until an input stops playback entirely. |
GuiElement#onEndVideo | callback [optional] onEndVideo() Called when the video is finished. |
Functions
- changeVideo
- copyAttributes
- delete
- disposeVideo
- draw
- getIsActive
- keyEvent
- loadFromXML
- loadProfile
- mouseEvent
- new
- onEndVideo
- playVideo
- stopVideo
- update
changeVideo
DescriptionDefinitionchangeVideo()Code
190 | function VideoElement:changeVideo(newVideoFilename, volume) |
191 | self:disposeVideo() |
192 | |
193 | self.videoFilename = newVideoFilename |
194 | if self.videoFilename ~= nil then |
195 | local videoFilename = string.gsub(self.videoFilename, "$l10nSuffix", g_gui.languageSuffix) |
196 | self.overlay = createVideoOverlay(videoFilename, self.isLooping, volume or self.volume) |
197 | end |
198 | end |
copyAttributes
DescriptionDefinitioncopyAttributes()Code
62 | function VideoElement:copyAttributes(src) |
63 | VideoElement:superClass().copyAttributes(self, src) |
64 | |
65 | self:changeVideo(src.videoFilename) |
66 | self.volume = src.volume |
67 | self.allowStop = src.allowStop |
68 | self.isLooping = src.isLooping |
69 | self.onEndVideoCallback = src.onEndVideoCallback |
70 | end |
delete
DescriptionDefinitiondelete()Code
74 | function VideoElement:delete() |
75 | self:disposeVideo() |
76 | VideoElement:superClass().delete(self) |
77 | end |
disposeVideo
DescriptionDefinitiondisposeVideo()Code
158 | function VideoElement:disposeVideo() |
159 | if self.overlay ~= nil then |
160 | self:stopVideo() |
161 | delete(self.overlay) |
162 | self.overlay = nil |
163 | end |
164 | end |
draw
DescriptionDefinitiondraw()Code
137 | function VideoElement:draw(clipX1, clipY1, clipX2, clipY2) |
138 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
139 | renderOverlay(self.overlay, self.absPosition[1], self.absPosition[2], self.size[1], self.size[2]) |
140 | end |
141 | VideoElement:superClass().draw(self, clipX1, clipY1, clipX2, clipY2) |
142 | end |
getIsActive
DescriptionDefinitiongetIsActive()Code
168 | function VideoElement:getIsActive() |
169 | return self:getIsVisible() |
170 | end |
keyEvent
DescriptionDefinitionkeyEvent()Code
106 | function VideoElement:keyEvent(unicode, sym, modifier, isDown, eventUsed) |
107 | if self:getIsActive() then |
108 | VideoElement:superClass().keyEvent(self, unicode, sym, modifier, isDown, eventUsed) |
109 | |
110 | if isDown then |
111 | if self.overlay ~= nil then |
112 | self:disposeVideo() |
113 | self:onEndVideo() |
114 | end |
115 | end |
116 | |
117 | return true |
118 | end |
119 | |
120 | return eventUsed |
121 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
36 | function VideoElement:loadFromXML(xmlFile, key) |
37 | VideoElement:superClass().loadFromXML(self, xmlFile, key) |
38 | |
39 | self.videoFilename = Utils.getNoNil(getXMLString(xmlFile, key.."#videoFilename"), self.videoFilename) |
40 | self.volume = Utils.getNoNil(getXMLFloat(xmlFile, key.."#volume"), self.volume) |
41 | self.allowStop = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowStop"), self.allowStop) |
42 | self.isLooping = Utils.getNoNil(getXMLBool(xmlFile, key.."#isLooping"), self.isLooping) |
43 | |
44 | self:addCallback(xmlFile, key.."#onEndVideo", "onEndVideoCallback") |
45 | |
46 | self:changeVideo(self.videoFilename) |
47 | end |
loadProfile
DescriptionDefinitionloadProfile()Code
51 | function VideoElement:loadProfile(profile, applyProfile) |
52 | VideoElement:superClass().loadProfile(self, profile, applyProfile) |
53 | |
54 | self.videoFilename = profile:getValue("videoFilename", self.videoFilename) |
55 | self.volume = profile:getNumber("volume", self.volume) |
56 | self.allowStop = profile:getBool("allowStop", self.allowStop) |
57 | self.isLooping = profile:getBool("isLooping", self.isLooping) |
58 | end |
mouseEvent
DescriptionDefinitionmouseEvent()Code
81 | function VideoElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) |
82 | if self:getIsActive() then |
83 | if VideoElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) then |
84 | eventUsed = true |
85 | end |
86 | |
87 | if not eventUsed and self.allowStop then |
88 | local ret = true |
89 | |
90 | if isDown then |
91 | if self.overlay ~= nil then |
92 | self:disposeVideo() |
93 | self:onEndVideo() |
94 | end |
95 | end |
96 | |
97 | return ret |
98 | end |
99 | end |
100 | |
101 | return eventUsed |
102 | end |
new
DescriptionDefinitionnew()Code
23 | function VideoElement.new(target, custom_mt) |
24 | local self = VideoElement:superClass().new(target, custom_mt or VideoElement_mt) |
25 | |
26 | self.videoFilename = nil |
27 | self.allowStop = true |
28 | self.isLooping = false |
29 | self.volume = 1.0 |
30 | |
31 | return self |
32 | end |
onEndVideo
DescriptionDefinitiononEndVideo()Code
146 | function VideoElement:onEndVideo() |
147 | if self.onEndVideoCallback ~= nil then |
148 | if self.target ~= nil then |
149 | self.onEndVideoCallback(self.target) |
150 | else |
151 | self.onEndVideoCallback() |
152 | end |
153 | end |
154 | end |
playVideo
DescriptionDefinitionplayVideo()Code
174 | function VideoElement:playVideo() |
175 | if self.overlay ~= nil then |
176 | playVideoOverlay(self.overlay) |
177 | end |
178 | end |
stopVideo
DescriptionDefinitionstopVideo()Code
182 | function VideoElement:stopVideo() |
183 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
184 | stopVideoOverlay(self.overlay) |
185 | end |
186 | end |
update
DescriptionDefinitionupdate()Code
125 | function VideoElement:update(dt) |
126 | VideoElement:superClass().update(self, dt) |
127 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
128 | updateVideoOverlay(self.overlay) |
129 | elseif self.overlay ~= nil then |
130 | self:disposeVideo() |
131 | self:onEndVideo() |
132 | end |
133 | end |