Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ContextActionDisplay
- DialogElement
- FieldInfoDisplay
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputHelpDisplay
- ListElement
- ListItemElement
- MapHotspot
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- SettingsModel
- SideNotification
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- StableListElement
- StatusBar
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TextElement
- TextInputElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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
193 | function VideoElement:changeVideo(newVideoFilename) |
194 | self:disposeVideo(); |
195 | |
196 | self.videoFilename = newVideoFilename; |
197 | if self.videoFilename ~= nil then |
198 | local videoFilename = string.gsub(self.videoFilename, "$l10nSuffix", g_gui.languageSuffix); |
199 | self.overlay = createVideoOverlay(videoFilename, self.isLooping, self.volume); |
200 | end; |
201 | end |
copyAttributes
DescriptionDefinitioncopyAttributes()Code
65 | function VideoElement:copyAttributes(src) |
66 | VideoElement:superClass().copyAttributes(self, src); |
67 | |
68 | self:changeVideo(src.videoFilename); |
69 | self.volume = src.volume; |
70 | self.allowStop = src.allowStop; |
71 | self.isLooping = src.isLooping; |
72 | self.onEndVideoCallback = src.onEndVideoCallback; |
73 | end |
delete
DescriptionDefinitiondelete()Code
77 | function VideoElement:delete() |
78 | self:disposeVideo(); |
79 | VideoElement:superClass().delete(self); |
80 | end |
disposeVideo
DescriptionDefinitiondisposeVideo()Code
161 | function VideoElement:disposeVideo() |
162 | if self.overlay ~= nil then |
163 | self:stopVideo(); |
164 | delete(self.overlay); |
165 | self.overlay = nil; |
166 | end; |
167 | end |
draw
DescriptionDefinitiondraw()Code
140 | function VideoElement:draw() |
141 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
142 | renderOverlay(self.overlay, self.absPosition[1], self.absPosition[2], self.size[1], self.size[2]) |
143 | end |
144 | VideoElement:superClass().draw(self) |
145 | end |
getIsActive
DescriptionDefinitiongetIsActive()Code
171 | function VideoElement:getIsActive() |
172 | return self:getIsVisible(); |
173 | end |
keyEvent
DescriptionDefinitionkeyEvent()Code
107 | function VideoElement:keyEvent(unicode, sym, modifier, isDown, eventUsed) |
108 | if self:getIsActive() then |
109 | if VideoElement:superClass().keyEvent(self, unicode, sym, modifier, isDown, eventUsed) then |
110 | eventUsed = true; |
111 | end; |
112 | local ret = eventUsed; |
113 | ret = true; |
114 | |
115 | if isDown then |
116 | if self.overlay ~= nil then |
117 | self:disposeVideo(); |
118 | self:onEndVideo(); |
119 | end; |
120 | end; |
121 | return ret; |
122 | end; |
123 | return eventUsed; |
124 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
39 | function VideoElement:loadFromXML(xmlFile, key) |
40 | VideoElement:superClass().loadFromXML(self, xmlFile, key); |
41 | |
42 | self.videoFilename = Utils.getNoNil(getXMLString(xmlFile, key.."#videoFilename"), self.videoFilename); |
43 | self.volume = Utils.getNoNil(getXMLFloat(xmlFile, key.."#volume"), self.volume); |
44 | self.allowStop = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowStop"), self.allowStop); |
45 | self.isLooping = Utils.getNoNil(getXMLBool(xmlFile, key.."#isLooping"), self.isLooping); |
46 | |
47 | self:addCallback(xmlFile, key.."#onEndVideo", "onEndVideoCallback"); |
48 | |
49 | self:changeVideo(self.videoFilename); |
50 | end |
loadProfile
DescriptionDefinitionloadProfile()Code
54 | function VideoElement:loadProfile(profile, applyProfile) |
55 | VideoElement:superClass().loadProfile(self, profile, applyProfile); |
56 | |
57 | self.videoFilename = profile:getValue("videoFilename", self.videoFilename); |
58 | self.volume = profile:getNumber("volume", self.volume); |
59 | self.allowStop = profile:getBool("allowStop", self.allowStop); |
60 | self.isLooping = profile:getBool("isLooping", self.isLooping); |
61 | end |
mouseEvent
DescriptionDefinitionmouseEvent()Code
84 | function VideoElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) |
85 | if self:getIsActive() then |
86 | if VideoElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) then |
87 | eventUsed = true; |
88 | end; |
89 | local ret = eventUsed; |
90 | if not eventUsed and self.allowStop then |
91 | ret = true; |
92 | |
93 | if isDown then |
94 | if self.overlay ~= nil then |
95 | self:disposeVideo(); |
96 | self:onEndVideo(); |
97 | end; |
98 | end; |
99 | return ret; |
100 | end; |
101 | end; |
102 | return eventUsed; |
103 | end |
new
DescriptionDefinitionnew()Code
23 | function VideoElement:new(target, custom_mt) |
24 | if custom_mt == nil then |
25 | custom_mt = VideoElement_mt; |
26 | end; |
27 | local self = GuiElement:new(target, custom_mt); |
28 | |
29 | self.videoFilename = nil; |
30 | self.allowStop = true; |
31 | self.isLooping = false; |
32 | self.volume = 1.0; |
33 | |
34 | return self; |
35 | end |
onEndVideo
DescriptionDefinitiononEndVideo()Code
149 | function VideoElement:onEndVideo() |
150 | if self.onEndVideoCallback ~= nil then |
151 | if self.target ~= nil then |
152 | self.onEndVideoCallback(self.target); |
153 | else |
154 | self.onEndVideoCallback(); |
155 | end; |
156 | end; |
157 | end |
playVideo
DescriptionDefinitionplayVideo()Code
177 | function VideoElement:playVideo() |
178 | if self.overlay ~= nil then |
179 | playVideoOverlay(self.overlay); |
180 | end; |
181 | end |
stopVideo
DescriptionDefinitionstopVideo()Code
185 | function VideoElement:stopVideo() |
186 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
187 | stopVideoOverlay(self.overlay); |
188 | end; |
189 | end |
update
DescriptionDefinitionupdate()Code
128 | function VideoElement:update(dt) |
129 | VideoElement:superClass().update(self, dt); |
130 | if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then |
131 | updateVideoOverlay(self.overlay); |
132 | elseif self.overlay ~= nil then |
133 | self:disposeVideo(); |
134 | self:onEndVideo(); |
135 | end; |
136 | end |