Loop and Autoplay Video with Pixi.js 5.2.1
See original GitHub issueHello! I am trying to implement autoplay and loop on a video (see code below) with Pixi.js@5.2.1 - My question is: bg.baseTexture.source.loop = true; - returns an uncaught TypeError - while the autoplay method works but for some reason the baseTexture.source.loop method does not. Thank you for checking this issue out. Has the most recent version of Pixi.js changed how - baseTexture.source.loop is called? Your comments and help are appreciated!
Here’s my code:
createBackgrounds() {
this.bgArray.map((video) => {
// create a video texture from a path
const bg = PIXI.Texture.from(`../assets/video/${video}.mp4`);
//assigning the texture to baseTexture.source.loop to loop video - and returns uncaught TypeError??
bg.baseTexture.source.loop = true;
const videoSprite = new PIXI.Sprite(bg);
videoSprite.anchor.x = 0.5;
videoSprite.anchor.y = 0.5;
// preload and autoplay video
videoSprite.preload = 'auto';
this.autoPlay = videoSprite.autoplay;
this.imgContainer.addChild(videoSprite);
this.bgSpriteArray.push(videoSprite);
// IMAGE
videoSprite.alpha = this.bgSpriteArray.length === 1 ? 1 : 0;
});
}```
Uncaught TypeError: Cannot set property 'loop' of undefined
at jello.js:199
at Array.map (<anonymous>)
at Jello.createBackgrounds (jello.js:194)
Reference: does the fact that source was deprecated have anything to do with the TypeError?
<img width="1407" alt="Screen Shot 2020-03-26 at 7 47 42 PM" src="https://user-images.githubusercontent.com/57849114/77716141-b2955800-6f9a-11ea-9d4a-f920511bd86e.png">
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Loop and Autoplay Video with Pixi.js 5.2.1 - Stack Overflow
I am trying to implement autoplay and loop on a video (see code below) with Pixi.js@5.2.1 - My question is: bg.baseTexture.source.loop ...
Read more >Loop and Autoplay Video with Pixi.js 5.2.1 #6501 - GitHub
I am trying to implement autoplay and loop on a video (see code below) with Pixi.js@5.2.1 - My question is: bg.baseTexture.source.loop = true;...
Read more >Unable to pause video immediately on load? - Pixi.js
Is there any way to pause a video immediately after creating the element with PIXI.Texture.fromVideo or fromVideoUrl?
Read more >问答- 腾讯云开发者社区-腾讯云
javascriptarraysvideohtml5-videopixi.js. 我正在尝试使用Pixi.js@5.2.1实现自动播放和视频循环(参见下面的代码)-我的问题是: bg.baseTexture.source.loop = true;- ...
Read more >Pixi's docs - PixiJS API Documentation
The PixiJS renderer allows everyone to enjoy the power of hardware acceleration without prior knowledge of WebGL. Also, it's fast. Really fast.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good stuff!! Great information! Thank you for your answers. Issue has been fixed and I have implemented autoplay and video loop. Thanks guys!
Awesome, closing.