Skip to content

Commit df6dc70

Browse files
committed
Various VideoTexture tests (this file will be removed shortly however).
1 parent 33ece1f commit df6dc70

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/pixi/textures/VideoTexture.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PIXI.VideoTexture = function(source, scaleMode)
1919
// hook in here to check if video is already available.
2020
// PIXI.BaseTexture looks for a source.complete boolean, plus width & height.
2121

22-
if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA ) && source.width && source.height)
22+
if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA) && source.width && source.height)
2323
{
2424
source.complete = true;
2525
}
@@ -61,8 +61,18 @@ PIXI.VideoTexture.prototype.play = function()
6161
this.onPlay.dispatch();
6262
};
6363

64-
PIXI.VideoTexture.prototype.changeSource = function(src)
64+
PIXI.VideoTexture.prototype.changeSource = function(src, type, loop)
6565
{
66+
if (typeof type === 'undefined') { type = "video/mp4"; }
67+
if (typeof loop === 'undefined') { loop = false; }
68+
69+
this.source.type = type;
70+
71+
if (loop)
72+
{
73+
this.source.loop = "loop";
74+
}
75+
6676
this.source.src = src;
6777
this.source.play();
6878
this.onPlay.dispatch();
@@ -97,8 +107,9 @@ PIXI.VideoTexture.prototype.onPlayStart = function()
97107
{
98108
if (!this.autoUpdate)
99109
{
100-
window.requestAnimationFrame(this.updateBound);
101110
this.autoUpdate = true;
111+
window.ds = "onPlayStart";
112+
window.requestAnimationFrame(this.updateBound);
102113
}
103114
};
104115

@@ -120,6 +131,7 @@ PIXI.VideoTexture.prototype.onCanPlay = function(event)
120131

121132
this.width = this.source.videoWidth;
122133
this.height = this.source.videoHeight;
134+
// this.autoUpdate = true;
123135

124136
// prevent multiple loaded dispatches..
125137
if (!this.__loaded )
@@ -197,28 +209,30 @@ PIXI.VideoTexture.textureFromVideo = function(video, scaleMode)
197209
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
198210
* @param autoPlay {boolean} Automatically start the video playing? Until you do this you can't get the width / height of the resulting texture.
199211
* @param type {string} The mime-type of the video to be played. Defaults to "video/mp4". Needed for Firefox and Safari.
212+
* @param loop {boolean} Should the loop property be set or not?
200213
* @return {VideoTexture}
201214
*/
202-
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay, type)
215+
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay, type, loop)
203216
{
204217
if (typeof scaleMode === 'undefined') { scaleMode = PIXI.scaleModes.DEFAULT; }
205218
if (typeof autoPlay === 'undefined') { autoPlay = true; }
206219
if (typeof type === 'undefined') { type = "video/mp4"; }
220+
if (typeof loop === 'undefined') { loop = false; }
207221

208222
var video = document.createElement('video');
209223

210224
video.src = videoSrc;
211225
video.controls = false;
212226
video.type = type;
213227

214-
if (autoPlay)
228+
if (loop)
215229
{
216-
video.autoplay = true;
217-
video.play();
230+
video.loop = "loop";
218231
}
219-
else
232+
233+
if (autoPlay)
220234
{
221-
video.autoplay = false;
235+
video.autoplay = "autoplay";
222236
}
223237

224238
return PIXI.VideoTexture.textureFromVideo(video, scaleMode);

0 commit comments

Comments
 (0)