LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

VideoElement

Description
Plays back a video.
Parent
GuiElement
XML Configuration Parameters
GuiElement#videoFileNamestring 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#volumefloat [optional] Playback volume, defaults to 1 (maximum).
GuiElement#allowStopbool [optional] If false, does not allow skipping the video by mouse click. Keyboard inputs will always skip the video.
GuiElement#isLoopingbool [optional] If true, the video is restarted when playback is finished until an input stops playback entirely.
GuiElement#onEndVideocallback [optional] onEndVideo() Called when the video is finished.

Functions

changeVideo

Description
Definition
changeVideo()
Code
193function 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;
201end

copyAttributes

Description
Definition
copyAttributes()
Code
65function 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;
73end

delete

Description
Definition
delete()
Code
77function VideoElement:delete()
78 self:disposeVideo();
79 VideoElement:superClass().delete(self);
80end

disposeVideo

Description
Definition
disposeVideo()
Code
161function VideoElement:disposeVideo()
162 if self.overlay ~= nil then
163 self:stopVideo();
164 delete(self.overlay);
165 self.overlay = nil;
166 end;
167end

draw

Description
Definition
draw()
Code
140function 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)
145end

getIsActive

Description
Definition
getIsActive()
Code
171function VideoElement:getIsActive()
172 return self:getIsVisible();
173end

keyEvent

Description
Definition
keyEvent()
Code
107function 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;
124end

loadFromXML

Description
Definition
loadFromXML()
Code
39function 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);
50end

loadProfile

Description
Definition
loadProfile()
Code
54function 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);
61end

mouseEvent

Description
Definition
mouseEvent()
Code
84function 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;
103end

new

Description
Definition
new()
Code
23function 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;
35end

onEndVideo

Description
Definition
onEndVideo()
Code
149function 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;
157end

playVideo

Description
Definition
playVideo()
Code
177function VideoElement:playVideo()
178 if self.overlay ~= nil then
179 playVideoOverlay(self.overlay);
180 end;
181end

stopVideo

Description
Definition
stopVideo()
Code
185function VideoElement:stopVideo()
186 if self.overlay ~= nil and isVideoOverlayPlaying(self.overlay) then
187 stopVideoOverlay(self.overlay);
188 end;
189end

update

Description
Definition
update()
Code
128function 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;
136end