Playing audio file using HTML 5 and jsp - html

I am trying to play an audio file, it works when I have a .html file but when I am running the same code in a .jsp file the file cannot be played. I am using Netbeans IDE. Could someone please point out the mistake, Here is the jsp code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<audio controls>
<source src="C:\Users\Desktop\1.mp3" type="audio/mpeg">
</audio>
</body>

The src attribute should not be the file location of the audio file. Instead, it should be the URL for the file. So in your case, try
<audio controls>
<source src="http://localhost:8080/PathToMp3/1.mp3" type="audio/mpeg">
</audio>
where http://localhost:8080/PathToMp3/1.mp3 is the url of your mp3 file.

<audio controls>
<source src="http://localhost:8080/PathToMp3/1.mp3" type="audio/mpeg">
</audio>
if it's not working use this
<embed src="">

Related

Audio won't autoplay

<!DOCTYPE html>
<html>
<body>
<audio controls autoplay>
<source src="Rick Roll.mp3" type="audio/mpeg">
</audio>
</body>
</html>
For some reason, it won't play automatically. Is it because the file is too big?
Media like video or audio will not play automatically anymore. This is a security thing. In order to play the media, user must interact with the page, like with a click.
There is a space in your src that is invalid.
<source src="Rick Roll.mp3" type="audio/mpeg">
Try for fix that(if is this):
<source src="RickRoll.mp3" type="audio/mpeg">

Why don't my vtt subtittles show up on my html5 video?

I'm trying to use subtitles with my HTML5 video tag, but I can't get this to work.
I think the issue is that the video source isn't a local file.
Does anyone know how I can get around this?
<html>
<head>
<style id="stndz-style"></style>
<meta name="viewport" content="width=device-width">
</head>
<body>
<video id="video" controls autoplay="" name="media">
<source src="http://localhost:8888/" type="video/mp4">
<track label="Dutch" kind="subtitles" srclang="nl" src="/home/ubuntu/Desktop/scripts/example.vtt" default>
</video>
</body>
</html>
and this is my example.vtt:
WEBVTT
00:01.000 --> 00:04.000
Never drink liquid nitrogen.
00:05.000 --> 00:09.000
- It will perforate your stomach.
- You could die.
Turns out that cromium not letting me use local files was the issue. So my workaround is to run chromium like this:
chromium --allow-file-access-from-files

audio file is not playing in html

I am unable play audio file in my html.Below code is sample
<html>
<body>
<audio controls>
<source src="http://localuat.virinchihospitals.com/vfImg/UploadAudio/1529667425971.mp3" type="audio/mpeg">
</audio>
</body>
</html>
I do not have privileges to comment, but it seems to me that your mp3 file does not exist, follow an example
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="http://www.orangefreesounds.com/wp-content/uploads/2016/12/Horse-and-carriage-passing-by.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
Your audio file is not right/valid its not working, Open this in your tab and see
http://localuat.virinchihospitals.com/vfImg/UploadAudio/1529667425971.mp3

HTML video not working

I am trying to get a video to play locally but it isn't working. the file is 'wildlife.mp4,' however, it doesn't play it is just a blank video box? Any help will be much appreciated, thanks.
<!DOCTYPE html>
<html>
<head>
<title>video</title>
</head>
<body>
<video width="320" height="240" controls>
<source src="wildlife.mp4" type="video/mp4">
<source src="wildlife.ogg" type="video/ogg">
Your browser does not support the video tag.
</body>
</html>
Video tag is not closed.
Add autoplay if you want the video to play automatically.
<!DOCTYPE html>
<html>
<head>
<title>video</title>
</head>
<body>
<video width="320" autoplay="autoplay" height="240" controls>
<source src="wildlife.mp4" type="video/mp4">
<source src="wildlife.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
If you are running the script on Windows the browser can check the file type associated with the video ( wildlife.mp4 ). On my system ( W7) I clicked the -Properties- on the video file and CHANGed the -Type of file- from VLC (which is the default on my system) to Windows Media player and all was sorted.
Hope this helps.

How to embed html video without using youtube

Apparently I'm a total noob when it comes to web development. I just need help making a simple html file that embeds a video. I can't use youtube. I just need to embed the local file and it's not working.
<!DOCTYPE html>
<head>
<title>Testing</title>
</head>
<body>
<video id="0" controls width="502" height="479">
<source src="OWA tutorial.webm" type='video/webm'>
<source src="OWA tutorial.mp4" type='video/mp4'>
<p>Video is not visible, most likely your browser does not support HTML5 video</p>
</video>
</body>
</html>
This doesn't work. "OWA tutorial.mp4" is in the same folder as the html file. What am I doing wrong?
Tried this:
<!DOCTYPE html>
<head>
<title>Testing</title>
</head>
<body>
<video id="0" width="502" height="479" controls>
<source src="loop.ogv" type="video/ogg">
<p>Video is not visible, most likely your browser does not support HTML5 video</p>
</video>
</body>
</html>
Worked well. Just replace the ogg with mp4, in your case.
Edit:
I'm not saying that you should use .ogv instead of .mp4.
I just used it as example because I've tried with a .ogv file (just because I don't have a .mp4 file here right now).
Your code should work if you copy mine and just replace the "loop.ogv" with your filename and the "video/ogg" with "video/mp4".
Sorry if it was misleading.