+ 6

How to insert mp3 to html on sololearn.

I want my page playing sounds. No code yet.

25th Feb 2020, 4:15 AM
高于鈞
高于鈞 - avatar
13 Respuestas
+ 5
不能。因為自動播放被灠用作廣告及其他不良目的,所以現代化的瀏覽器禁止autoplay。 autoplay is not allowed in modern browsers, to protect users from bad user experience. https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide AudioElement.play() 函數,必須,我重申,是必須,由一個滑鼠動作發動。(UserGesture)
25th Feb 2020, 8:13 AM
Gordon
Gordon - avatar
+ 5
you cannot upload any media content directly to sololearn codeplay ground First you need to upload it on Dropbox or somewhere to get link of that content and then paste the link on audio tag.. review this threads https://www.sololearn.com/discuss/1054246/?ref=app
25th Feb 2020, 5:04 AM
Scooby
Scooby - avatar
+ 2
<audio> <source src="yourfile.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
25th Feb 2020, 4:21 AM
Gabriel Ilie
Gabriel Ilie - avatar
+ 2
Scooby Thanks!
25th Feb 2020, 6:02 AM
高于鈞
高于鈞 - avatar
+ 2
在JavaScript裡,要有一個函數,用play()。 這個函數必須是mouse event callback。 示範 1: https://code.sololearn.com/Wl23AIEG6SuZ/?ref=app 示範 2: https://code.sololearn.com/WelW4JX7EYPD/?ref=app
25th Feb 2020, 6:02 AM
Gordon
Gordon - avatar
+ 2
no, sololearn app doesn't have the file system authorization. You can use on html files of your own computer to reference audio files in C:\ though.
25th Feb 2020, 12:05 PM
Gordon
Gordon - avatar
+ 1
Gabriel Ilie If I don't insert mp3 file can I play sounds by trans mp3 to some code and play it?
25th Feb 2020, 4:24 AM
高于鈞
高于鈞 - avatar
+ 1
Gordon 可以用自動播放嗎
25th Feb 2020, 6:11 AM
高于鈞
高于鈞 - avatar
+ 1
Gordon 感謝
25th Feb 2020, 10:54 AM
高于鈞
高于鈞 - avatar
+ 1
Scooby Gordon 那我可以離線在sololearn廣場做出同樣的功能嗎 Can I do this offline on sololearn playground?
25th Feb 2020, 11:33 AM
高于鈞
高于鈞 - avatar
+ 1
Gordon 那我可以用把mp3轉成某種編碼來實現在playground播放的功能嗎,我之前有看過有人好像把mp3轉成base64可以在playground上播放
26th Feb 2020, 12:49 AM
高于鈞
高于鈞 - avatar
0
88888 P
26th Feb 2020, 11:44 PM
[No Name]
0
mp3也能在code playground的Web Code播放。 是不能自動播放,但是有按鍵(可以是document)的話,mp3也能播放。
29th Feb 2020, 1:38 PM
Gordon
Gordon - avatar