{"id":648,"date":"2011-05-30T19:31:54","date_gmt":"2011-05-30T17:31:54","guid":{"rendered":"http:\/\/www.kavdesign.net\/blog\/?p=648"},"modified":"2011-05-30T19:31:54","modified_gmt":"2011-05-30T17:31:54","slug":"how-to-put-a-sound-on-your-website","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-put-a-sound-on-your-website\/","title":{"rendered":"How to put a sound on your website?"},"content":{"rendered":"<p>I use flash to achieve this. Create a new flash file with AS3. Create two buttons which will be placed one above the other. The stop button instance is called xstop and the play button instance is called xplay.<\/p>\n<p>And this is the code:<\/p>\n<pre>\r\n\/\/think of the soundchannel as a speaker system and the sound as an mp3 player\r\nvar soundChannel:SoundChannel = new SoundChannel();\r\nvar sound:Sound = new Sound(new URLRequest(\"http:\/\/www.kavdesign.net\/sites\/stgeorge\/birds1.mp3\"));\r\n\r\nxstop.addEventListener(MouseEvent.CLICK, clickStop);\r\nxplay.addEventListener(MouseEvent.CLICK, clickPlay);\r\n\r\nplayMusic();\r\n\r\nfunction clickPlay(evt:MouseEvent) {\r\n\tplayMusic();\r\n}\r\n\r\nfunction clickStop(evt:MouseEvent) {\r\n\t\tsoundChannel.stop();\r\n\t\tsoundChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);\r\n\t\txstop.visible = false;\r\n\t\txplay.visible = true;\r\n}\r\n\r\nfunction playMusic():void\r\n\t{\r\n\t\t soundChannel = sound.play();\r\n\t\t soundChannel.addEventListener(Event.SOUND_COMPLETE, loopMusic);\r\n\t\t xstop.visible = true;\r\n\t\t xplay.visible = false;\r\n\t}\r\n\r\nfunction loopMusic(e:Event):void\r\n\t{\r\n\t\t if (soundChannel != null)\r\n\t\t {\r\n\t\t\t  soundChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);\r\n\t\t\t  playMusic();\r\n\t\t }\r\n\t}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I use flash to achieve this. Create a new flash file with AS3. Create two buttons which will be placed one above the other. The&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-put-a-sound-on-your-website\/\">Continue reading<span class=\"screen-reader-text\">How to put a sound on your website?<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9],"tags":[71,12],"class_list":["post-648","post","type-post","status-publish","format-standard","hentry","category-coding","tag-flash","tag-music","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=648"}],"version-history":[{"count":1,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":649,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions\/649"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}