diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 2e7719b..b2a2807 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -317,6 +317,7 @@ { if (!type) { + path = path.split('?').shift().toLowerCase(); type = `video/${path.substr(path.lastIndexOf('.') + 1)}`; } diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 2e7719b..b2a2807 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -317,6 +317,7 @@ { if (!type) { + path = path.split('?').shift().toLowerCase(); type = `video/${path.substr(path.lastIndexOf('.') + 1)}`; } diff --git a/test/core/VideoBaseTexture.js b/test/core/VideoBaseTexture.js new file mode 100644 index 0000000..f9b61ad --- /dev/null +++ b/test/core/VideoBaseTexture.js @@ -0,0 +1,28 @@ +'use strict'; + +describe('PIXI.VideoBaseTexture', function () +{ + afterEach(function () + { + this.texture.destroy(); + this.texture = null; + }); + + it('should find correct video extension from Url', function () + { + this.texture = new PIXI.VideoBaseTexture.fromUrl('https://example.org/video.webm'); + + expect(this.texture.source.firstChild.type).to.be.equals('video/webm'); + + this.texture.destroy(); + }); + + it('should get video extension without being thrown by query string', function () + { + this.texture = new PIXI.VideoBaseTexture.fromUrl('/test.mp4?123...'); + + expect(this.texture.source.firstChild.type).to.be.equals('video/mp4'); + + this.texture.destroy(); + }); +}); diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 2e7719b..b2a2807 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -317,6 +317,7 @@ { if (!type) { + path = path.split('?').shift().toLowerCase(); type = `video/${path.substr(path.lastIndexOf('.') + 1)}`; } diff --git a/test/core/VideoBaseTexture.js b/test/core/VideoBaseTexture.js new file mode 100644 index 0000000..f9b61ad --- /dev/null +++ b/test/core/VideoBaseTexture.js @@ -0,0 +1,28 @@ +'use strict'; + +describe('PIXI.VideoBaseTexture', function () +{ + afterEach(function () + { + this.texture.destroy(); + this.texture = null; + }); + + it('should find correct video extension from Url', function () + { + this.texture = new PIXI.VideoBaseTexture.fromUrl('https://example.org/video.webm'); + + expect(this.texture.source.firstChild.type).to.be.equals('video/webm'); + + this.texture.destroy(); + }); + + it('should get video extension without being thrown by query string', function () + { + this.texture = new PIXI.VideoBaseTexture.fromUrl('/test.mp4?123...'); + + expect(this.texture.source.firstChild.type).to.be.equals('video/mp4'); + + this.texture.destroy(); + }); +}); diff --git a/test/core/index.js b/test/core/index.js index e0ec004..27998e7 100755 --- a/test/core/index.js +++ b/test/core/index.js @@ -32,5 +32,6 @@ require('./Ellipse'); require('./BaseTexture'); require('./Texture'); +require('./VideoBaseTexture'); require('./Ticker'); require('./filters');