Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Embedding video and audio

    Hi,
    I can usually find the answers to html-related questions either via google or the forum search. This time I am stumped. I would appreciate any tricks that can fix the following.

    I need to embed video and audio on a page. That is it. Or rather, how can I embed a file and let the browser choose the plugin? I can't seem to find any reference to any tag that will do this in the current versions of html.

    The EMBED tag used to do this back in the bad old days. Nowadays all I find are convoluted variations of object tags. All those workarounds require that I (the developer of the page) decide which plugin the visitor should use to best display a certain file format. There are several plugins for various browsers that all handle mpeg4, 3gpp, mp3. Even pdf can be viewed by more than one plugin. I can't (and frankly wouldn't want to) know which plugin the visitor prefers.

    How can I embed an "object" at /path/to/file which is of the type some/media and let the browser choose the plugin? Is that still an utopia after all these years? I haven't dealt with this in a few years and I am honestly surprised I can't find any solid example.

    thanks in advance.
    /Martin

  • #2
    New Coder
    Join Date
    Aug 2006
    Posts
    64
    Thanks
    0
    Thanked 1 Time in 1 Post
    The below should do it without any crap javascript or anything else. You also need to use the correct mimetype for the filetype you are using and that should then pickup the correct module to use. i.e. type= the valid mime type for your file type.
    The embed tag is required if the browser being used doesn't support activex modules and therefore is using plugin modules as opposed to activex modules. You could leave the embed tag out but it won't work on some machines, particularly older macs.

    Code:
         <object id="myid" style="width:100px;height:100px;" data="pathto/myflashfile.swf" type="application/x-shockwave-flash">
          <param name="movie" value="pathto/myflashfile.swf" />
          <embed src="pathto/myflashfile.swf" width="100" height="100" name="myid" align="" type="application/x-shockwave-flash" ></embed>
      </object>
    p.s. since the modules you may be running are programs which usually require telling what to do, you must provide the correct param entries, if required, to make it start and behave according to how you want it to behave. i.e. the modules aren't telepathic so you can't assume it will do what you want it to do such as just open and play the file, although it might if you are lucky.
    Last edited by percepts; 04-27-2009 at 07:20 PM.

  • Users who have thanked percepts for this post:

    eimermusic (04-28-2009)

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by eimermusic View Post
    Hi,
    I can usually find the answers to html-related questions either via google or the forum search. This time I am stumped. I would appreciate any tricks that can fix the following.

    I need to embed video and audio on a page. That is it. Or rather, how can I embed a file and let the browser choose the plugin? I can't seem to find any reference to any tag that will do this in the current versions of html.

    The EMBED tag used to do this back in the bad old days. Nowadays all I find are convoluted variations of object tags. All those workarounds require that I (the developer of the page) decide which plugin the visitor should use to best display a certain file format. There are several plugins for various browsers that all handle mpeg4, 3gpp, mp3. Even pdf can be viewed by more than one plugin. I can't (and frankly wouldn't want to) know which plugin the visitor prefers.

    How can I embed an "object" at /path/to/file which is of the type some/media and let the browser choose the plugin? Is that still an utopia after all these years? I haven't dealt with this in a few years and I am honestly surprised I can't find any solid example.

    thanks in advance.
    /Martin
    The JW FLV Media player (http://www.longtailvideo.com/players/jw-flv-player/) is a very popular option as it plays a number of popular filetypes (FLV, MP4, MP3, AAC, JPG, PNG and GIF). It also supports playlists, which is very nice. According to the website it supports "RTMP, HTTP, live streaming, various playlists formats".

    It's a free download for personal use (I believe a "donation" is suggested for commercial use) and it has pretty good online support (also boasts an online setup wizard here: http://www.longtailvideo.com/support...r-setup-wizard) if you get lost in the installation or customization -- yes, it can be skinned. It is javascript-based and there are limitations of course (for example, it won't play WMV or WMA files), but there is a reason that this player is so popular... Besides, any user who is open to playing online A/V content is probably not the sort of user who has javascript disabled -- just food for thought.

    Anyway, this doesn't use embed or object tags at all. Once the base code is included in the header with a <link> tag the in-page script call is done like so:
    Code:
    <script type='text/javascript' src='/embed/swfobject.js'></script>
    
      <div id='mediaspace'>This div will be replaced</div>
    
      <script type='text/javascript'>
      var s1 = new SWFObject('/jw/embed/player.swf','ply','470','320','9','#ffffff');
      s1.addParam('allowfullscreen','true');
      s1.addParam('allowscriptaccess','always');
      s1.addParam('wmode','opaque');
      s1.addParam('flashvars','file=http://content.bitsontherun.com/videos/3ta6fhJQ.flv');
      s1.write('mediaspace');
    </script>
    That's it. The media player appears inside of the "mediaspace" div in this case. The existing text is overwritten with the player.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your suggestions guys.
    It looks like percepts suggestion is what I am looking for. I was under the impression that a "certain popular browser" required classid and a bunch of stuff. I'll give that tag a try.

    Using a Flash wrapper to play the files is something I'd like to avoid. For a "normal" page to publish some videos, sure but in this case I don't know in advance which filetypes are going to pop up. The interface in question is a kind of "admin" for data from mobile phones and they can send out any number of strange formats of audio and video.

    Thanks to you both for being helpful.


  •  

    Tags for this Thread

    Posting Permissions

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