Unmount audio/video tag when exiting player

This commit is contained in:
DC
2016-09-23 01:15:51 -07:00
parent 0dd1683298
commit 3b6819f894
2 changed files with 9 additions and 5 deletions

View File

@@ -17,10 +17,6 @@ class UnplayableFileError extends PlaybackError {
constructor () { super('Can\'t play that file') } constructor () { super('Can\'t play that file') }
} }
class PlaybackTimedOutError extends PlaybackError {
constructor () { super('Playback timed out. Try again.') }
}
/* Sound */ /* Sound */
class InvalidSoundNameError extends SoundError { class InvalidSoundNameError extends SoundError {
@@ -42,7 +38,6 @@ module.exports = {
TorrentError, TorrentError,
UnplayableTorrentError, UnplayableTorrentError,
UnplayableFileError, UnplayableFileError,
PlaybackTimedOutError,
InvalidSoundNameError, InvalidSoundNameError,
TorrentKeyNotFoundError, TorrentKeyNotFoundError,
InvalidTorrentError InvalidTorrentError

View File

@@ -26,6 +26,15 @@ module.exports = class Player extends React.Component {
</div> </div>
) )
} }
onComponentWillUnmount () {
// Unload the media element so that Chromium stops trying to fetch data
const tag = document.querySelector('audio,video')
if (!tag) return
tag.pause()
tag.src = ''
tag.load()
}
} }
// Handles volume change by wheel // Handles volume change by wheel