Can I have I hand on this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can I have I hand on this?

I have issues adding an audio to my code. The audio is saved on my device as Space.mp3 and precisely in /storage/download/Music. This was the code I generated for the <body> part. <body> <audio controls> <Source src="Space.mp3" type="audio/mpeg"> <Source src="Space.ogg" type="audio/ogg'> Audio element not supported by your browser. </audio> </body> But this only shows the audio image on the output page without being able to play. Is my code correct? Or is there any changes I need to make to avert this issue. Please rewrite the code if mine is wrong or has issues. Thanks and God bless😊

16th Apr 2022, 5:59 AM
Gabriel
Gabriel - avatar
8 Answers
+ 4
Second thing which many times happened with me, the documents must be inside the same folder. I have tried using relative path like `../../Picture/somePic.jpg` but it doesn't work. So, move your audio file to current dir as the next step to make thing correct according to me.
16th Apr 2022, 6:09 AM
lokesh
lokesh - avatar
+ 3
First things first, audio element was introduced in HTML5. So, make sure your webpage/HTML document have doctype declaration <!DOCTYPE html> element at the very top of your document.
16th Apr 2022, 6:07 AM
lokesh
lokesh - avatar
+ 3
tell me what works and what not
16th Apr 2022, 6:37 AM
lokesh
lokesh - avatar
+ 3
lokesh Yeah that's true, I've also tried external path but didn't work, the audio will work only if the all the current documents and medias are in the same folder.
16th Apr 2022, 10:21 AM
Cyber Nate
Cyber Nate - avatar
+ 2
Cyber Nate thanks for understanding I thought it only happens with me. Maybe My code editor has set a path or some setting for that, cause for any file type there is a relative path or absolute path. But I just understood (or maybe not) that relative path of html is not same as linux filesystem navigation where we change dir, etc. Relative path in HTML is the other file relative to the current file and must be inside same dir. And absolute path can attach a file from the internet meaning from a website which is already hosted and working, ex: an image link from unsplash.
16th Apr 2022, 11:55 AM
lokesh
lokesh - avatar
+ 2
Open Google Files app and click info or i button on your audio and copy the URL. This is a perfect URL for localhost ;)
16th Apr 2022, 1:07 PM
Ravinder Jakhar Jat
Ravinder Jakhar Jat - avatar
+ 1
lokesh Thanks but what do you mean by current dir
16th Apr 2022, 6:21 AM
Gabriel
Gabriel - avatar
+ 1
current directory in linux/folder in windows.
16th Apr 2022, 6:37 AM
lokesh
lokesh - avatar