-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
RS_VideoControl.js
215 lines (203 loc) · 6.98 KB
/
RS_VideoControl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//================================================================
// RS_VideoControl.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2016 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* RS_VideoControl.js
* @plugindesc This plugin allows you to indicate the play control bar of a video
* @author biud436
*
* @param zIndex
* @desc range of the z-index is a number between 0 and 2147483647.
* @default 1000
* @min 0
* @max 2147483647
*
* @param Show Control Bar
* @type boolean
* @desc Set whether shows a control bar on a video
* @default true
*
* @help
* =============================================================================
* Plugin Command
* =============================================================================
*
* This plugin command shows up the control bar with Html Video Element.
* VideoControl show true
*
* This plugin command hides the control bar with Html Video Element.
* VideoControl show false
*
* In the all of html elements, They have a z-depth value.
* They have a default z-index, as follows.
* Game Canvas : 1
* Video Element : 2
* Loading Element : 3
* Mode Box ELement : 9
* Error Printer Element : 99
*
* this plugin command allows you to change the z-index value for video element.
*
* VideoControl zIndex 1000
*
* To change Playback Rate value for video, you can use this plugin command.
* its default value is to 1.0.
* the 0.5 value is to slow the playback speeds by 50%,
* the 2.0 value is the playback speeds up by 2X.
*
* VideoControl playbackRate 1.0
*
* This plugim command plays the video from any time without playing it from 0.0 seconds.
* The 'src' is the actual name of the movie file with the missing extension.
* The 'time' is the value of the time to play.
* VideoControl src time
*
* =============================================================================
* Change Log
* =============================================================================
* 2016.05.07 (v1.0.0) - First Release
* 2016.10.21 (v1.0.1) - Fixed some funtions (RMMV 1.3.2)
* 2017.06.10 (v1.0.2) - Fixed the plugin command and the code for RMMV 1.5.0
* 2019.02.28 (v1.0.3) - Added some plugin commands.
*/
/*:ko
* @plugindesc 이 플러그인은 기본 동영상 재생 시 컨트롤 바를 같이 띄웁니다.
* @author biud436
*
* @param zIndex
* @text Z 인덱스
* @desc z-index는 0이상 2147483647이하의 숫자입니다.
* @default 1000
* @min 0
* @max 2147483647
*
* @param Show Control Bar
* @text 컨트롤바 표시
* @type boolean
* @desc 동영상 재생 시 컨트롤 바를 표시할 지 감출 지를 선택하세요.
* @default true
*
* @help
* =============================================================================
* 플러그인 명령에 대해
* =============================================================================
*
* 다음 명령은 컨트롤 바를 표시합니다.
* VideoControl show true
*
* 다음 명령은 컨트롤 바를 감춥니다.
* VideoControl show false
*
* 다음 명령은 동영상 요소의 Z 인덱스를 수정합니다.
*
* 각 요소의 기본 Z 깊이 값은 다음과 같습니다.
*
* Game Canvas : 1 (게임 캔버스)
* Video Element : 2 (동영상)
* Loading Element : 3 (로딩)
* Mode Box ELement : 9 (FPS 등 표시)
* Error Printer Element : 99 (오류 표시)
*
* VideoControl zIndex 1000
*
* 동영상 재생 속도를 변경합니다.
* 1.0이 기본 재생 속도이며,
* 2.0은 2배 빠른 속도로 재생되고,
* 0.5는 50% 느린 속도로 재생됩니다.
* VideoControl playbackRate 1.0
*
* 동영상을 0.0초부터 재생하지 않고 임의의 시간부터 재생합니다.
* src는 확장자가 생략된 동영상 파일의 실제 이름이며,
* time은 재생 할 시간 값입니다.
* VideoControl src time
*
* =============================================================================
* 변동 사항
* =============================================================================
* 2016.05.07 (v1.0.0) - First Release
* 2016.10.21 (v1.0.1) - Fixed some funtions (RMMV 1.3.2)
* 2017.06.10 (v1.0.2) - Fixed the plugin command and the code for RMMV 1.5.0
* 2019.02.28 (v1.0.3) - Added some plugin commands.
*/
var Imported = Imported || {};
Imported.RS_VideoControl = true;
var RS = RS || {};
RS.VideoControl = RS.VideoControl || {};
(function($) {
"use strict";
var parameters = PluginManager.parameters('RS_VideoControl');
$.Params = $.Params || {};
$.Params.zIndex = Number(parameters['zIndex'] || 1000);
$.Params.enabledContol = parameters['Show Control Bar'] === 'true';
$.Params.playbackRate = 1.0;
//----------------------------------------------------------------------------
// Graphics
//
//
Graphics.setVideoCurrentTime = function(value) {
if (this._video && value > 0) {
if( ( value + 0.0001 ) < this._video.duration) {
this._video.currentTime = value;
}
}
};
Graphics.setVideoPlaybackRate = function(value) {
if (this._video) {
if(value < 0) value = 0.0;
this._video.playbackRate = value;
}
};
Graphics.getVideoDuration = function() {
if (this._video) {
return this._video.duration;
}
return 0.0;
};
var alias_Graphics_updateVideo = Graphics._updateVideo;
Graphics._updateVideo = function() {
alias_Graphics_updateVideo.call(this);
if(this._video) {
this._video.style.zIndex = $.Params.zIndex;
this._video.controls = $.Params.enabledContol;
}
this.setVideoPlaybackRate($.Params.playbackRate);
};
//----------------------------------------------------------------------------
// Game_Interpreter
//
//
var alias_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
alias_pluginCommand.call(this, command, args);
if(command === "VideoControl") {
switch (args[0].toLowerCase()) {
case 'show':
$.Params.enabledContol = Boolean(args[1] === 'true');
break;
case 'zindex':
$.Params.zIndex = Number(args[1] || 1000);
break;
case 'playbackRate':
$.Params.playbackRate = parseFloat(args[1] || 1.0);
break;
case 'play':
var name = args[1];
var time = parseFloat(args[2]) || 0.0;
if (name.length > 0 && !$gameMessage.isBusy()) {
var ext = this.videoFileExt();
Graphics.playVideo('movies/' + name + ext);
if(time > 0.0) {
Graphics.setVideoCurrentTime(time);
}
this.setWaitMode('video');
}
break;
}
}
};
})(RS.VideoControl);