Results 1 to 8 of 8

Thread: Embed Video and Audio onto Website

  1. #1
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Embed Video and Audio onto Website

    I am looking for some javascript that will load and play music or video on my websites.

    I used to use the following javascripts but these NO longer work:

    <embed src="/help/mediaplayer.swf?file=video.wmv" width"854" height="480" allowfallowfullscreen="true" />
    and
    <embed height="50" width="100" src="/myaudiofiles/example.mp3">

    Why these NO longer work I can not image. I would appreciate any help I can get.

    Thanks very much

  2. #2
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    this will work for just the audio only; you need to find a play and a pause .png, if you fiind a jpeg then change that in the code
    Code:
    <style type="text/css">
    audio {visibility: hidden; height: 0; width: 0; position: absolute; top: -300px; left: -300px;}
    #pauseplay {float: right; width: 48px; height: 48px; overflow: hidden; cursor: pointer}
    </style>
    
    <audio controls loop>
    <source src="audio/waves.ogg" type="audio/ogg">
    <source src="audio/waves.mp3" type="audio/mpeg">
    </audio>
    <img id="pauseplay" src="images/play.png" alt="button" title="Play/Pause">
    <script type="text/javascript">
    (function(){
    	var playing = !!('ontouchstart' in window) || !!('ontouchstart' in document.documentElement) || !!window.ontouchstart || (!!window.Touch && !!window.Touch.length) || !!window.onmsgesturechange || (window.DocumentTouch && window.document instanceof window.DocumentTouch),
    	snd = document.getElementsByTagName('audio')[0],
    	ctrl = document.getElementById('pauseplay');
    	playing = !playing;
    	ctrl.title = playing? 'Pause' : 'Play';
    	if(playing){snd.autoplay = false; ctrl.src = 'images/pause.png';}
    	ctrl.addEventListener('click', function(){
    		if(playing){
    			snd.pause();
    		} else {
    			snd.play();
    		}
    		playing = !playing;
    		ctrl.title = playing? 'Pause' : 'Play';
    		ctrl.src = playing? 'images/pause.png' : 'images/play.png';
    	}, false);
    })();
    </script>
    this is it live on one of my websites
    this is what I used on that website for the icons
    Click image for larger version. 

Name:	play.jpg 
Views:	157 
Size:	6.4 KB 
ID:	5767 Click image for larger version. 

Name:	pause.jpg 
Views:	159 
Size:	5.5 KB 
ID:	5768
    Last edited by mlegg; 12-26-2015 at 03:47 PM.

  3. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    That's a very old method. You don't *need* JavaScript anymore - HTML5 comes with native video and audio elements.

    Mozilla docs info https://developer.mozilla.org/en-US/...udio_and_video

    My contributions
    - Audio: http://fofwebdesign.co.uk/freebies-f...s.php?sort=aud
    - Video: http://fofwebdesign.co.uk/freebies-f...s.php?sort=vid
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  4. The Following User Says Thank You to Beverleyh For This Useful Post:

    Ripsaw (01-04-2016)

  5. #4
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I guess I am NOT as smart as I thought I was.

    mlegg I understand your code is for audio only and I have NOT tried it yet but I will

    Beverleyh I have tried the audio script and for life of me I can NOT get it to work.

    A little more help might help. Thank you

  6. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Which audio script have you tried? There are 4 in the filtered results I linked to.

    Unfortunately we can't troubleshoot something we can't see so please post a link to your page.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #6
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I feel like a Bumb Butt. I am using Dreamweaver 8 to create my webpages. Dreamweaver has a built-in media function that embeds either audio or video with a minimum of effort. It just took me a while it out.

    I do appreciate the responses.

  8. #7
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Grrrrrrrrrrrrr I tried a video and in Dreamweaver, it tested fine but when uploaded to my service it does NOT work. Now I am back to ground zero

  9. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I tried a video and in Dreamweaver, it tested fine
    hmm, now does this mean that you stayed within the Dreamweaver environment? As in, does it give you a live preview mode from within the web builder software? I can't really help you there, and I'm not sure that anyone else here will be able to either as we tend not to use web building software. How about when you save the files and test locally by opening the page in a web browser (not in Dreamweaver)?

    If it works locally and not online, check that all the assets/resources are uploaded and that paths are correct. Also check file names, extensions and paths for case (Windows environments are not case-sensitive, whereas UNIX environments are). Paths may cause issues to if they're saved like they're meant for a local computer; C:\ type paths (i.e. absolute from your computer's C drive) do not work online, so check those. Failing that we'd need to see a link to the page in order to offer further suggestions.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Controlling video's coming from a video sharing website
    By molendijk in forum Submit a DHTML or CSS code
    Replies: 3
    Last Post: 11-20-2009, 01:05 PM
  2. Embed Video and Audio files
    By kennyzita in forum PHP
    Replies: 2
    Last Post: 10-20-2009, 02:30 PM
  3. Flash Video no audio/other
    By bluewalrus in forum Flash
    Replies: 3
    Last Post: 06-23-2008, 05:02 AM
  4. Embed hidden audio autoplay in Firefox
    By dbuckley in forum HTML
    Replies: 3
    Last Post: 01-10-2008, 05:04 AM
  5. embed audio stream into website (problem)
    By rodster69 in forum Other
    Replies: 5
    Last Post: 01-10-2007, 04:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •