Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-27-2009, 06:40 PM   PM User | #1
eimermusic
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
eimermusic is an unknown quantity at this point
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
eimermusic is offline   Reply With Quote
Old 04-27-2009, 06:55 PM   PM User | #2
percepts
New Coder

 
Join Date: Aug 2006
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
percepts has a little shameless behaviour in the past
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..
percepts is offline   Reply With Quote
Users who have thanked percepts for this post:
eimermusic (04-28-2009)
Old 04-27-2009, 08:54 PM   PM User | #3
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
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
Rowsdower! is offline   Reply With Quote
Old 04-28-2009, 01:40 PM   PM User | #4
eimermusic
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
eimermusic is an unknown quantity at this point
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.
eimermusic is offline   Reply With Quote
Reply

Bookmarks

Tags
embed, html

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:46 AM.


Advertisement
Log in to turn off these ads.