diff --git a/app/src/component/mediaPlayer/view.js b/app/src/component/mediaPlayer/view.js index b2db5e51..2caafc31 100644 --- a/app/src/component/mediaPlayer/view.js +++ b/app/src/component/mediaPlayer/view.js @@ -30,6 +30,7 @@ class MediaPlayer extends React.PureComponent { constructor(props) { super(props); this.state = { + encodedFilePath: null, rate: 1, volume: 1, muted: false, @@ -284,9 +285,15 @@ class MediaPlayer extends React.PureComponent { } getEncodedDownloadPath = (fileInfo) => { + if (this.state.encodedFilePath) { + return this.state.encodedFilePath; + } + const { file_name: fileName } = fileInfo; const encodedFileName = encodeURIComponent(fileName).replace(/!/g, '%21'); - return fileInfo.download_path.replace(new RegExp(fileName, 'g'), encodedFileName); + const encodedFilePath = fileInfo.download_path.replace(fileName, encodedFileName); + this.setState({ encodedFilePath }); + return encodedFilePath; } render() {