Audio tag in blogspot, Audio tag half working in blogspot |
Audio tag in blogspot, Audio tag half working in blogspot |
Retrotechy |
Jul 21 2023, 04:34 PM
Post
#1
|
Group: Members Posts: 3 Joined: 21-July 23 Member No.: 28,991 |
Hi all.
First post on a great forum. Unfortunately it’s a shout out for help please. I have a blogger blog and have tried to put in an auto play audio tag into the main forum landing page. As the landing page isn’t a post, I have put the audio tag html in the theme html in the body. When you navigate to the page from the website address or a browser, the audio doesn’t play, but if you open a post then use the back button to go back to the landing page, the audio then plays fine. Can anyone advise why this is happening? Initially the audio had no visual but I added the controls attribute and it looks like the auto play attribute isn’t initially kicking in, but does kick in when you hit the back button back to Landing page. |
Christian J |
Jul 22 2023, 04:47 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,722 Joined: 10-August 06 Member No.: 7 |
Hi and welcome!
Hard to say without seeing the page. Could it be that the audio simply haven't had time to load? In theory a javascript on the page may only start the player if there's a Referer header (or even a cookie set on the other pages), but that sounds farfetched (also I can't remember if using the Back button sends a Referer header). Many users may also disable autoplay in their own browser settings, but then it should never work of course. |
Retrotechy |
Jul 24 2023, 08:30 AM
Post
#3
|
Group: Members Posts: 3 Joined: 21-July 23 Member No.: 28,991 |
Hi.
Thanks for the reply! The website is a blogspot blog and my audio playing code inserted into the body of the page is this: <b:if cond='data:blog.url == "https://mr-flibbles-lair.blogspot.com/"'> <audio autoplay='1' controls='1' id='myaudio' loop='1'> <source src='https://andy-lawson.uk/Mr Flibbles Lair/Red Dwarf - Series 7/Music Cues/8 Rimmer Munchkin Song.mp3' type='audio/mpg'/> </audio> </b:if> I made the control panel temporarily visible so that I could see that the link to the audio file was being picked up, and that the <b:if> tag was activating correctly for that URL only. Everything looks good so I am assuming that on first landing that the autoplay is blocked, but still cant figure why going back to the page allows it to play. |
pandy |
Jul 24 2023, 12:36 PM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,753 Joined: 9-August 06 Member No.: 6 |
I don't know blogger lingo, but I doubt the quotes here should be escaped.
QUOTE CODE <b:if cond='data:blog.url == "https://mr-flibbles-lair.blogspot.com/"'> Also, spaces aren't allowed in URLs. They need to be URL encoded, escaped with %20. Like this. CODE Red%20Dwarf%20-%20Series%207/Music%20Cues/8%20Rimmer%20Munchkin%20Song.mp3 It's much easier not to use spaces in file names. Use underscores or hyphens as word separators. But I don't think this is your problem. Modern browsers tend to mend that mistake. Instead I think this is the problem. Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed. https://www.w3schools.com/tags/att_audio_autoplay.asp And I think that probably goes for FF too. You had commented out the audio on your page. I removed the comments. Didn't auto play. Neither in FF nor Edge. But it starts to play as soon as the volume control is touched. I guess that is what "muted autoplay" means. And when I loaded the page in an older gecko browser it did autoplay. So that's my guess, browsers don't allow it anymore. |
Christian J |
Jul 24 2023, 02:53 PM
Post
#5
|
. Group: WDG Moderators Posts: 9,722 Joined: 10-August 06 Member No.: 7 |
I don't know blogger lingo Me neither. But it looks like the following is an IF condition that checks the URL of the blog: CODE <b:if cond='data:blog.url == "https://mr-flibbles-lair.blogspot.com/"'> <audio autoplay='1' controls='1' id='myaudio' loop='1'> <source src='https://andy-lawson.uk/Mr Flibbles Lair/Red Dwarf - Series 7/Music Cues/8 Rimmer Munchkin Song.mp3' type='audio/mpg'/> </audio> </b:if> --but since the quotes are incorrect the URL becomes messed up, and the IF conditions returns false (and the AUDIO element is not rendered by Blogspot?). But that still doesn't explain why it works when using the Back button. QUOTE Instead I think this is the problem. Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed. https://www.w3schools.com/tags/att_audio_autoplay.asp And I think that probably goes for FF too. There are setting for this in my browsers, but I can't remember what the defaults are. QUOTE You had commented out the audio on your page. I removed the comments. You mean the IF condition above? |
coothead |
Jul 24 2023, 03:24 PM
Post
#6
|
Advanced Member Group: Members Posts: 226 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
Hi there Retrotechy,
coothead |
pandy |
Jul 24 2023, 04:38 PM
Post
#7
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,753 Joined: 9-August 06 Member No.: 6 |
Online it was audio/mp3. I never checked if that's kosher, but I did change to audio/mpeg and it still didn't work for me.
|
coothead |
Jul 24 2023, 06:51 PM
Post
#8
|
Advanced Member Group: Members Posts: 226 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
. but I did change to audio/mpeg and it still didn't work for me.
coothead |
coothead |
Jul 24 2023, 07:09 PM
Post
#9
|
Advanced Member Group: Members Posts: 226 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
Hi there pandy,
coothead |
Retrotechy |
Jul 25 2023, 06:04 AM
Post
#10
|
Group: Members Posts: 3 Joined: 21-July 23 Member No.: 28,991 |
Hi,
Many thanks for all of the responses and info. I have removed / adjusted spaces in the mp3 URL and also corrected the type to mpeg but still no joy. I am guessing that the autoplay prohibited unless muted function is the reason it wont play. Many thanks for all of the comments and advice. |
pandy |
Jul 25 2023, 09:12 AM
Post
#11
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,753 Joined: 9-August 06 Member No.: 6 |
OK. But it doesn't mention content-type. But I looked it up and audio/mp3 doesn't seem to exist, so audio/mpeg as you said. But neither worked for me. I'm on Windows, so I guess browsers differ between OS. |
coothead |
Jul 25 2023, 01:04 PM
Post
#12
|
Advanced Member Group: Members Posts: 226 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
But neither worked for me. I'm on Windows, so I guess browsers differ between OS.
coothead |
Lo-Fi Version | Time is now: 26th September 2024 - 11:37 AM |