DOMException: Failed to load because no supported source was found

后端 未结 7 652
既然无缘
既然无缘 2020-11-30 08:20

I\'m getting DOMException: Failed to load because no supported source was found in video.play(); line. I\'m getting this issue only after adding video.setAt

7条回答
  •  孤街浪徒
    2020-11-30 09:01

    I had the same problem, but the cause was the file name contained a '#'.

    Apparently, if the file name contains a '#' I would get net::ERR_FILE_NOT_FOUND if setting the src directly to the string

    document.getElementById('audio').src = '../path/x#y.webm';
    console.log(document.getElementById('audio').src); // C:\Users\x\y\z\path\x#y.webm
    

    But would get a DOMException: The element has no supported sources. when using node's path.resolve even though the html element's src attribute would be the same

    document.getElementById('audio').src = path.resolve('path', 'x#y.webm');
    console.log(document.getElementById('audio').src); // C:\Users\x\y\z\path\x#y.webm
    

    Renaming the file name to x-y.webm resolved the issue.

    This was using electron on windows, it may not be the case on other os's or on web apps.

提交回复
热议问题