mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-11 16:18:10 +00:00
Merge pull request #181 from thewhodidthis/bf#168--movie
Post PIXI upgrade tweaks
This commit is contained in:
commit
abe30c9c6a
@ -425,7 +425,9 @@ export class Window extends PsychObject
|
||||
this._size[1] = window.innerHeight;
|
||||
|
||||
// create a PIXI renderer and add it to the document:
|
||||
this._renderer = PIXI.autoDetectRenderer(this._size[0], this._size[1], {
|
||||
this._renderer = PIXI.autoDetectRenderer({
|
||||
width: this._size[0],
|
||||
height: this._size[1],
|
||||
backgroundColor: this.color.int,
|
||||
resolution: window.devicePixelRatio
|
||||
});
|
||||
|
@ -172,20 +172,17 @@ export class MovieStim extends VisualStim
|
||||
this.psychoJS.logger.debug(`set the movie of MovieStim: ${this._name} as: src= ${movie.src}, size= ${movie.videoWidth}x${movie.videoHeight}, duration= ${movie.duration}s`);
|
||||
}
|
||||
|
||||
const clone = movie.cloneNode();
|
||||
|
||||
this._setAttribute('movie', clone, log);
|
||||
|
||||
const onended = () =>
|
||||
// Make sure just one listener attached across instances
|
||||
// https://stackoverflow.com/questions/11455515
|
||||
if (!movie.onended)
|
||||
{
|
||||
// Change stimulus status when movie done playing
|
||||
this.status = PsychoJS.Status.FINISHED;
|
||||
// Equivalent to giving the listener below an option of `{ once: true }`
|
||||
this._movie.removeEventListener('ended', onended);
|
||||
};
|
||||
|
||||
this._movie.addEventListener('ended', onended);
|
||||
movie.onended = () =>
|
||||
{
|
||||
this.status = PsychoJS.Status.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
this._setAttribute('movie', movie, log);
|
||||
this._needUpdate = true;
|
||||
this._needPixiUpdate = true;
|
||||
}
|
||||
@ -370,7 +367,7 @@ export class MovieStim extends VisualStim
|
||||
}
|
||||
|
||||
// create a PixiJS video sprite:
|
||||
this._texture = PIXI.Texture.fromVideo(this._movie);
|
||||
this._texture = PIXI.Texture.from(this._movie);
|
||||
this._pixi = new PIXI.Sprite(this._texture);
|
||||
|
||||
// since _texture.width may not be immedialy available but the rest of the code needs its value
|
||||
|
Loading…
Reference in New Issue
Block a user