From f65fc68179a374bf48ec4f81dbcb80c11218b433 Mon Sep 17 00:00:00 2001 From: Julen Garcia Leunda Date: Thu, 19 Sep 2019 22:14:21 +0200 Subject: [PATCH 01/12] Add --no-sandbox option to desktop files --- package.json | 2 +- static/linux/webtorrent-desktop.ejs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6db88aa2..c06ee3dd 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "install-system-deps": "brew install fakeroot dpkg rpm", "open-config": "node ./bin/open-config.js", "package": "node ./bin/package.js", - "start": "npm run build && electron .", + "start": "npm run build && electron --no-sandbox .", "test": "standard && depcheck --ignores=standard,babel-eslint --ignore-dirs=build,dist && node ./bin/extra-lint.js", "test-integration": "npm run build && node ./test", "update-authors": "./bin/update-authors.sh", diff --git a/static/linux/webtorrent-desktop.ejs b/static/linux/webtorrent-desktop.ejs index af143b6e..e88789cc 100644 --- a/static/linux/webtorrent-desktop.ejs +++ b/static/linux/webtorrent-desktop.ejs @@ -5,7 +5,7 @@ Name=<%= productName %> <% if (genericName) { %>GenericName=<%= genericName %><% } %> <% if (description) { %>Comment=<%= description %><% } %> Icon=<%= name %> -<% if (name) { %>Exec=<%= name %> %U<% } %> +<% if (name) { %>Exec=<%= name %> --no-sandbox %U<% } %><%/*HACK: --no-sandbox fixes an Electron 6 bug. See: #1703*/%> Terminal=false Actions=CreateNewTorrent;OpenTorrentFile;OpenTorrentAddress; <% if (mimeType && mimeType.length) { %>MimeType=<%= mimeType.join(';') %>;<% } %> @@ -15,12 +15,12 @@ StartupNotify=true [Desktop Action CreateNewTorrent] Name=Create New Torrent... -<% if (name) { %>Exec=<%= name %> -n <% } %> +<% if (name) { %>Exec=<%= name %> --no-sandbox -n <% } %><%/*HACK: --no-sandbox fixes an Electron 6 bug. See: #1703*/%> [Desktop Action OpenTorrentFile] Name=Open Torrent File... -<% if (name) { %>Exec=<%= name %> -o <% } %> +<% if (name) { %>Exec=<%= name %> --no-sandbox -o <% } %><%/*HACK: --no-sandbox fixes an Electron 6 bug. See: #1703*/%> [Desktop Action OpenTorrentAddress] Name=Open Torrent Address... -<% if (name) { %>Exec=<%= name %> -u <% } %> +<% if (name) { %>Exec=<%= name %> --no-sandbox -u <% } %><%/*HACK: --no-sandbox fixes an Electron 6 bug. See: #1703*/%> From 5023651e63110d40f52dadac79f1732248140fdf Mon Sep 17 00:00:00 2001 From: hicom150 Date: Wed, 25 Sep 2019 22:23:35 +0200 Subject: [PATCH 02/12] Improve codec unsupported detection --- src/renderer/pages/player-page.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 43f610d6..5d6fa37d 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -1,5 +1,3 @@ -/* global HTMLMediaElement */ - const React = require('react') const Bitfield = require('bitfield') const prettyBytes = require('prettier-bytes') @@ -56,6 +54,14 @@ function renderMedia (state) { mediaElement.pause() } else if (!state.playing.isPaused && mediaElement.paused) { mediaElement.play() + .then(() => { + dispatch('mediaSuccess') + }) + .catch((err) => { + if (err.name === 'NotSupportedError') { + dispatch('mediaError', 'Codec unsupported') + } + }) } // When the user clicks or drags on the progress bar, jump to that position if (state.playing.jumpToTime != null) { @@ -127,10 +133,8 @@ function renderMedia (state) { onLoadedMetadata={onLoadedMetadata} onEnded={onEnded} onStalled={dispatcher('mediaStalled')} - onError={dispatcher('mediaError')} onTimeUpdate={dispatcher('mediaTimeUpdate')} onEncrypted={dispatcher('mediaEncrypted')} - onCanPlay={onCanPlay} > {trackTags} @@ -168,20 +172,6 @@ function renderMedia (state) { if (state.window.isFullScreen) dispatch('toggleFullScreen') } } - - function onCanPlay (e) { - const elem = e.target - if (elem.readyState < HTMLMediaElement.HAVE_FUTURE_DATA) return - if (state.playing.type === 'video' && - elem.webkitVideoDecodedByteCount === 0) { - dispatch('mediaError', 'Video codec unsupported') - } else if (elem.webkitAudioDecodedByteCount === 0) { - dispatch('mediaError', 'Audio codec unsupported') - } else { - dispatch('mediaSuccess') - elem.play() - } - } } function renderOverlay (state) { From 8ee27b8ef45aa3f3d8c80cb2a4072ab7062dc22c Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Thu, 26 Sep 2019 20:49:17 -0400 Subject: [PATCH 03/12] Floor individual file percentages for display Fixes #1713 --- src/renderer/pages/torrent-list-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/torrent-list-page.js b/src/renderer/pages/torrent-list-page.js index 5c4123ca..4e8ed5f4 100644 --- a/src/renderer/pages/torrent-list-page.js +++ b/src/renderer/pages/torrent-list-page.js @@ -316,7 +316,7 @@ module.exports = class TorrentList extends React.Component { torrentSummary.progress.files[index]) { const fileProg = torrentSummary.progress.files[index] isDone = fileProg.numPiecesPresent === fileProg.numPieces - progress = Math.round(100 * fileProg.numPiecesPresent / fileProg.numPieces) + '%' + progress = Math.floor(100 * fileProg.numPiecesPresent / fileProg.numPieces) + '%' } // Second, for media files where we saved our position, show how far we got From 8a235c31e0fe6c44d2ea3005de1cb781b37082fd Mon Sep 17 00:00:00 2001 From: Lucas <5874806+RecoX@users.noreply.github.com> Date: Tue, 1 Oct 2019 11:05:53 +1300 Subject: [PATCH 04/12] mono is needed to create setup.exe --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51557b66..8a721366 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,12 @@ install [XQuartz](http://www.xquartz.org/), then run: brew install wine ``` +Also to generate the .exe setup we need to install [Mono](https://www.mono-project.com/) + +``` +brew install mono +``` + (Requires the [Homebrew](http://brew.sh/) package manager.) #### Mac build notes @@ -164,7 +170,6 @@ If packaging from Mac, install system dependencies with Homebrew by running: ``` npm run install-system-deps ``` - #### Recommended readings to start working in the app Electron (Framework to make native apps for Windows, OSX and Linux in Javascript): From cb699b5fec235c25cfe96005955ea81c057ff8db Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 30 Sep 2019 21:48:56 -0700 Subject: [PATCH 05/12] readme: clarify windows homebrew instructions --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8a721366..78099b83 100644 --- a/README.md +++ b/README.md @@ -142,17 +142,12 @@ The Windows app can be packaged from **any** platform. Note: Windows code signing only works from **Windows**, for now. Note: To package the Windows app from non-Windows platforms, -[Wine](https://www.winehq.org/) needs to be installed. For example on Mac, first -install [XQuartz](http://www.xquartz.org/), then run: +[Wine](https://www.winehq.org/) and [Mono](https://www.mono-project.com/) need +to be installed. For example on Mac, first install +[XQuartz](http://www.xquartz.org/), then run: ``` -brew install wine -``` - -Also to generate the .exe setup we need to install [Mono](https://www.mono-project.com/) - -``` -brew install mono +brew install wine mono ``` (Requires the [Homebrew](http://brew.sh/) package manager.) From 8fc7150559d60e472cab61996875e9be7a7824c1 Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Thu, 3 Oct 2019 02:22:12 -0400 Subject: [PATCH 06/12] Report when files are being verified When starting a torrent that is partially-downloaded, WebTorrent will now report "Verifying" as it verifies the existing data on disk. Fixes #1586 --- src/renderer/pages/torrent-list-page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/pages/torrent-list-page.js b/src/renderer/pages/torrent-list-page.js index 4e8ed5f4..286e9acf 100644 --- a/src/renderer/pages/torrent-list-page.js +++ b/src/renderer/pages/torrent-list-page.js @@ -212,7 +212,9 @@ module.exports = class TorrentList extends React.Component { else if (torrentSummary.progress.progress === 1) status = 'Not seeding' else status = 'Paused' } else if (torrentSummary.status === 'downloading') { - status = 'Downloading' + if (!torrentSummary.progress) status = '' + else if (!torrentSummary.progress.ready) status = 'Verifying' + else status = 'Downloading' } else if (torrentSummary.status === 'seeding') { status = 'Seeding' } else { // torrentSummary.status is 'new' or something unexpected From 3fbf33b8ae1dd162da2b15a894ef3b0f195a42d7 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 6 Oct 2019 14:52:23 -0700 Subject: [PATCH 07/12] remove borewit from funding.yml (per his request) --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d183cee9..27381237 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1 @@ github: feross -custom: https://paypal.me/borewit From d4a8d9a1200d793dae43557ab647d5d800c714a0 Mon Sep 17 00:00:00 2001 From: hicom150 Date: Mon, 7 Oct 2019 17:54:36 +0200 Subject: [PATCH 08/12] Apply review changes --- src/renderer/pages/player-page.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 5d6fa37d..8dc39f2f 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -54,14 +54,10 @@ function renderMedia (state) { mediaElement.pause() } else if (!state.playing.isPaused && mediaElement.paused) { mediaElement.play() - .then(() => { - dispatch('mediaSuccess') - }) - .catch((err) => { - if (err.name === 'NotSupportedError') { - dispatch('mediaError', 'Codec unsupported') - } - }) + .then( + () => dispatch('mediaSuccess'), + () => dispatch('mediaError', 'Codec unsupported') + ) } // When the user clicks or drags on the progress bar, jump to that position if (state.playing.jumpToTime != null) { From 5c64fb5d351d4380d08561701d65b28914fecb16 Mon Sep 17 00:00:00 2001 From: Borewit Date: Mon, 7 Oct 2019 20:01:19 +0200 Subject: [PATCH 09/12] Update music-metadata to v4.8.0 --- package-lock.json | 21 ++++++++++++++------- package.json | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index fbf2160b..f543c149 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1955,6 +1955,7 @@ "version": "0.10.1", "resolved": "https://registry.npmjs.org/cross-spawn-promise/-/cross-spawn-promise-0.10.1.tgz", "integrity": "sha1-25y0xQxgtyoVvgSbeBIs44LYexA=", + "optional": true, "requires": { "cross-spawn": "^5.1.0" }, @@ -1963,6 +1964,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "optional": true, "requires": { "lru-cache": "^4.0.1", "shebang-command": "^1.2.0", @@ -2497,6 +2499,7 @@ "version": "0.7.3", "resolved": "https://registry.npmjs.org/electron-installer-common/-/electron-installer-common-0.7.3.tgz", "integrity": "sha512-l4chYFTWr6uWODKYUXeC+Z4tqGa3b8e+Y2WUBf3F7Ruv6yYzZ+Ccic65oXreeotx09B7sUx1KTuwXRsRJHKlMw==", + "optional": true, "requires": { "asar": "^2.0.1", "cross-spawn-promise": "^0.10.1", @@ -2513,6 +2516,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "optional": true, "requires": { "ms": "^2.1.1" } @@ -2521,6 +2525,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "optional": true, "requires": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -2570,7 +2575,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/electron-installer-redhat/-/electron-installer-redhat-2.0.0.tgz", "integrity": "sha512-kf7+/t8XIp1I6LIV9v6K38rBHzmY6bUr3TunJZKdlIKQ7j6wyjjpgbpxSBcg3S7pgzq1kkgCYZvpr8CsLFVivw==", - "dev": true, + "optional": true, "requires": { "debug": "^4.1.1", "electron-installer-common": "^0.7.1", @@ -2584,7 +2589,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, + "optional": true, "requires": { "ms": "^2.1.1" } @@ -2593,7 +2598,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, + "optional": true, "requires": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -5640,9 +5645,9 @@ } }, "music-metadata": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-4.5.3.tgz", - "integrity": "sha512-VXIr9hGJyxcdyqOlUmn+c4wM8f1FAyLyxV12L1pYC5Zb/MKElrh2JmGTLBSy23DN27uBA4QbqhfOOtkvd9H6Mw==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-4.8.0.tgz", + "integrity": "sha512-eQp9mDTwg8WEqVRIEj1lUuqZ4qiQvXa71ipotkPFKch4ekTAtGTzU/TXAi7DhCeHsZB8WLfGUBTFN1NGBE1iOQ==", "requires": { "content-type": "^1.0.4", "debug": "^4.1.0", @@ -9062,6 +9067,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-2.0.2.tgz", "integrity": "sha512-zl71nFWjPKW2KXs+73gEk8RmqvtAeXPxhWDkTUoa3MSMkjq3I+9OeknjF178MQoMYsdqL730hfzvNfEkePxq9Q==", + "optional": true, "requires": { "tmp": "0.1.0" } @@ -10045,7 +10051,8 @@ "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "optional": true }, "wordwrap": { "version": "0.0.2", diff --git a/package.json b/package.json index 6db88aa2..80fcbd3d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "location-history": "^1.1.1", "material-ui": "^0.20.2", "mkdirp": "^0.5.1", - "music-metadata": "^4.5.3", + "music-metadata": "^4.8.0", "network-address": "^1.1.2", "parse-torrent": "^7.0.1", "prettier-bytes": "^1.0.4", From 3d85803df99ea5da6d5551d8be28a6d2c870d841 Mon Sep 17 00:00:00 2001 From: hicom150 Date: Wed, 25 Sep 2019 22:23:35 +0200 Subject: [PATCH 10/12] Improve codec unsupported detection --- src/renderer/pages/player-page.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 43f610d6..5d6fa37d 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -1,5 +1,3 @@ -/* global HTMLMediaElement */ - const React = require('react') const Bitfield = require('bitfield') const prettyBytes = require('prettier-bytes') @@ -56,6 +54,14 @@ function renderMedia (state) { mediaElement.pause() } else if (!state.playing.isPaused && mediaElement.paused) { mediaElement.play() + .then(() => { + dispatch('mediaSuccess') + }) + .catch((err) => { + if (err.name === 'NotSupportedError') { + dispatch('mediaError', 'Codec unsupported') + } + }) } // When the user clicks or drags on the progress bar, jump to that position if (state.playing.jumpToTime != null) { @@ -127,10 +133,8 @@ function renderMedia (state) { onLoadedMetadata={onLoadedMetadata} onEnded={onEnded} onStalled={dispatcher('mediaStalled')} - onError={dispatcher('mediaError')} onTimeUpdate={dispatcher('mediaTimeUpdate')} onEncrypted={dispatcher('mediaEncrypted')} - onCanPlay={onCanPlay} > {trackTags} @@ -168,20 +172,6 @@ function renderMedia (state) { if (state.window.isFullScreen) dispatch('toggleFullScreen') } } - - function onCanPlay (e) { - const elem = e.target - if (elem.readyState < HTMLMediaElement.HAVE_FUTURE_DATA) return - if (state.playing.type === 'video' && - elem.webkitVideoDecodedByteCount === 0) { - dispatch('mediaError', 'Video codec unsupported') - } else if (elem.webkitAudioDecodedByteCount === 0) { - dispatch('mediaError', 'Audio codec unsupported') - } else { - dispatch('mediaSuccess') - elem.play() - } - } } function renderOverlay (state) { From f5e186dc67069eec8d9d1f96af72015d7c3de13a Mon Sep 17 00:00:00 2001 From: hicom150 Date: Mon, 7 Oct 2019 17:54:36 +0200 Subject: [PATCH 11/12] Apply review changes --- src/renderer/pages/player-page.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 5d6fa37d..a087b3b9 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -54,14 +54,13 @@ function renderMedia (state) { mediaElement.pause() } else if (!state.playing.isPaused && mediaElement.paused) { mediaElement.play() - .then(() => { - dispatch('mediaSuccess') - }) - .catch((err) => { - if (err.name === 'NotSupportedError') { + .then( + () => dispatch('mediaSuccess'), + (err) => { + console.error(`Error playing mediaElement: ${err.name}`) dispatch('mediaError', 'Codec unsupported') } - }) + ) } // When the user clicks or drags on the progress bar, jump to that position if (state.playing.jumpToTime != null) { From f2c531baa4c20a531b5133f564e7be3f6c8f9e50 Mon Sep 17 00:00:00 2001 From: hicom150 Date: Sat, 12 Oct 2019 17:44:13 +0200 Subject: [PATCH 12/12] use videoTracks and audioTracks to check unsupported codecs --- src/main/windows/about.js | 3 ++- src/main/windows/main.js | 3 ++- src/main/windows/webtorrent.js | 3 ++- src/renderer/pages/player-page.js | 45 +++++++++++++++++++++---------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/main/windows/about.js b/src/main/windows/about.js index fc16d517..1e6d6dc5 100644 --- a/src/main/windows/about.js +++ b/src/main/windows/about.js @@ -25,7 +25,8 @@ function init () { title: 'About ' + config.APP_WINDOW_TITLE, useContentSize: true, webPreferences: { - nodeIntegration: true + nodeIntegration: true, + enableBlinkFeatures: 'AudioVideoTracks' }, width: 300 }) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index dbfb7d0c..11aad3d0 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -44,7 +44,8 @@ function init (state, options) { useContentSize: true, // Specify web page size without OS chrome width: initialBounds.width, webPreferences: { - nodeIntegration: true + nodeIntegration: true, + enableBlinkFeatures: 'AudioVideoTracks' }, x: initialBounds.x, y: initialBounds.y diff --git a/src/main/windows/webtorrent.js b/src/main/windows/webtorrent.js index 8c58043b..cd08e225 100644 --- a/src/main/windows/webtorrent.js +++ b/src/main/windows/webtorrent.js @@ -26,7 +26,8 @@ function init () { title: 'webtorrent-hidden-window', useContentSize: true, webPreferences: { - nodeIntegration: true + nodeIntegration: true, + enableBlinkFeatures: 'AudioVideoTracks' }, width: 150 }) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index a087b3b9..b9998d13 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -54,13 +54,6 @@ function renderMedia (state) { mediaElement.pause() } else if (!state.playing.isPaused && mediaElement.paused) { mediaElement.play() - .then( - () => dispatch('mediaSuccess'), - (err) => { - console.error(`Error playing mediaElement: ${err.name}`) - dispatch('mediaError', 'Codec unsupported') - } - ) } // When the user clicks or drags on the progress bar, jump to that position if (state.playing.jumpToTime != null) { @@ -132,6 +125,7 @@ function renderMedia (state) { onLoadedMetadata={onLoadedMetadata} onEnded={onEnded} onStalled={dispatcher('mediaStalled')} + onError={dispatcher('mediaError')} onTimeUpdate={dispatcher('mediaTimeUpdate')} onEncrypted={dispatcher('mediaEncrypted')} > @@ -151,15 +145,38 @@ function renderMedia (state) { ) - // As soon as we know the video dimensions, resize the window function onLoadedMetadata (e) { - if (state.playing.type !== 'video') return - const video = e.target - const dimensions = { - width: video.videoWidth, - height: video.videoHeight + const mediaElement = e.target + + // check if we can decode video and audio track + if (state.playing.type === 'video') { + if (mediaElement.videoTracks.length === 0) { + dispatch('mediaError', 'Video codec unsupported') + } + + if (mediaElement.audioTracks.length === 0) { + dispatch('mediaError', 'Audio codec unsupported') + } + + dispatch('mediaSuccess') + + const dimensions = { + width: mediaElement.videoWidth, + height: mediaElement.videoHeight + } + + // As soon as we know the video dimensions, resize the window + dispatch('setDimensions', dimensions) + } + + // check if we can decode audio track + if (state.playing.type === 'audio') { + if (mediaElement.audioTracks.length === 0) { + dispatch('mediaError', 'Audio codec unsupported') + } + + dispatch('mediaSuccess') } - dispatch('setDimensions', dimensions) } function onEnded (e) {