question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loop and Autoplay Video with Pixi.js 5.2.1

See original GitHub issue

Hello! 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Plunky33commented, Mar 27, 2020

Good stuff!! Great information! Thank you for your answers. Issue has been fixed and I have implemented autoplay and video loop. Thanks guys!

0reactions
bigtimebuddycommented, Mar 27, 2020

Awesome, closing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found