Halloween Animation with Audio
by JayNick - uploaded on October 20, 2017, 11:57 pm
Animated Halloween SVG image with embedded audio file using a Base64 encoded data URI. Audio is a snippet of a file licensed CC0 from freesound.org It is coded to loop repeatedly.
Works on a Mac with desktop browsers, Firefox, Chrome, and Safari. Expect it to work on Windows and Linux, but did not test. It did not work with IOS mobile browsers Safari and Firefox.
Could not get to work using SVG's audio element, but worked with SVG's foreignObject element containing an HTML audio element.
Please leave a comment if tested in another environment - working or not - or if there is a better way to do this. Thanks.
- Tags
- audio broom cartoon child comic Comic characters costume cute female ghost girl grey halloween hat Holidays & Special Days magic orange pumpkin purple request+completed scene SMIL STEAMcoded.org sweets symbol twins
- Safe for Work?
- Yes
Remixes
No remixes yet — be the first.
Want to remix this clipart?
- Download the SVG
- Edit it in your favourite SVG editor
- Upload with Upload Remix (links automatically)
Sources
No catalog sources linked yet.
I found this clipart!
Related Finds — Openclipart spotted in the wild. Browse all · Atom
No Finds yet.
Log in to post a Found.
Comments
@Lazur
2017-10-21 09:35:35+00Nice one!
The first svg I've seen with sound. Works on win with chrome&firefox.
Edge has the audio working, but not the animation.
There is a "flick" in the sound, not sure if it's supposed to be there or just a "rendering" "feature".
@JayNick
2017-10-21 11:23:10+00Thanks for checking on Windows browsers.
The sound clip was to long, so I spliced beginning and end. I should have paid more attention to the quality, but I didn’t hear it with my poor hearing and testing with low volume.
@AdamStanislav
2017-10-21 19:53:49+00Works with 64-bit Opera 42.0, too (on a Windows 10 laptop).
@j4p4n
2017-10-22 07:17:01+00The thumbnail doesn't render? nice one though :)
@rejon
2017-10-30 20:54:35+00Nice
@slang121
2017-11-12 04:20:12+00cool. looks good
@Lazur
2017-12-04 02:59:50+00What did you use to turn the audio file to mpeg and how could you encode it to base64? Trying notepad++ to decode your file but can't seem to get a valid mpeg.
Also somehow embedding base64 encoded mp3 is ignored by the browsers. Is mpeg the only way to go?
@AdamStanislav
2017-12-04 04:05:20+00In Notepad++ select everything in the Base64 starting with the //uQZ all the way to the final qo= (but not the ">), copy it, open a new document, paste it in that document, press ctl-v to select everything, convert from Base64, save as new.mpg (or witch.mpg, or anything.mpg), and you have it. VLC plays it, I have not tested other players, but they should play it, too.
@JayNick
2017-12-05 04:10:01+00@Lazur URH - I used Audacity to crop the sound file and save it as an mp3, then used Mac command line tool, uuencode, to generate the base64 data. Reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
I used mp3 (mime type: audio/mpeg) because it is the only format supported by all the major browsers. Reference https://www.w3schools.com/html/html5_audio.asp
@Lazur
2017-12-05 06:47:26+00@JayNick Interesting. Was looking at the codes but the media type mpeg got me confused.
Now figuring out how to add that smil animation... and if it can be triggered by clicking on an object.
@JayNick
2017-12-05 13:59:56+00@Lazur URH Yes you can trigger SMIL animation by clicking on an object. Use the beginElement() method. Reference https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimationElement
Log in to comment.