Results 1 to 6 of 6

Thread: Dynamically change embedded video source

  1. #1
    Member silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    189

    Question Dynamically change embedded video source 2 Sep 2010 @ 15.21

    Hey web wizards,

    Is there anyone who can help me with the dreaded embedded video issue? I have code to embed video into my site using object for IE and embed for firefox. This works fine but now I also wish to dynamically change the source of the video depending on which link is clicked. I know how to acheive this but I believe that my source changing code for firefox is flawed

    My code for IE which works great is :

    <a href="#" onclick = "document.all.player1.Filename = 'new.wmv';"> Link</a>

    But for firefox and opera (which also seems to like <embed> rather than <object>) I have the code below:

    <a href="#" onClick = "document.embeds['p1'].src = ('new.wmv'); ">Link</a>

    A simple problem but one which has cost me hours of time already so any help would be much appreciated.
      Reply With Quote

  2. #2
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    712

    Default 2 Sep 2010 @ 16.15

    Look carefully at your code for FF & Opera. It says "onClick" (capital C). Try changing that to "onclick" (lowercase C).

    WMV seems an odd choice of video format for the web. Why not use Flash?

    For what it's worth, I'm encoding my video as Flash and playing it with Flowplayer (which can also handle WMV). Flowplayer has an excellent API for operations such as switching the source file.
      Reply With Quote

  3. #3
    Member MinatureCookie's Avatar
    Join Date
    Jan 2009
    Posts
    275

    Default 2 Sep 2010 @ 18.27

    Yeah it would probably be a lot easier and more cross-browser like if you made just a simple Flash player (or even downloaded one, there are quite a few for free) that ran a WMV file, and then changed the file dynamically through ActionScript (which can be manipulated using JavaScript)
    [FONT=Georgia]MinatureCookie.com[/FONT]
      Reply With Quote

  4. #4
    Member silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    189

    Default 3 Sep 2010 @ 12.59

    Hey,
    Thanks for your input, the capital letter was just a type error but anyway I still cant access the video source object. Can anyone explain how to embed windows media player into a page so that it works in all major browsers?
    thanks
      Reply With Quote

  5. #5
    Member MinatureCookie's Avatar
    Join Date
    Jan 2009
    Posts
    275

    Default 3 Sep 2010 @ 19.34

    As in the actual Windows Media Player, in the browser? Don't. Your users will all have to install a plugin - and I it's annoying to get, I'd doubt anyone would bother. I definitely wouldn't.
    And again - I'd still really recommend Flash, but... If you insist on the way you're doing it.

    The reason, most likely, is that when you embed media you have to state the source twice.
    Code:
    <object width="550" height="400">
    <param id="movieParam" name="movie" value="somefilename.swf">
    <embed id="movieEmbed" src="somefilename.swf" width="550" height="400">
    </embed>
    </object>
    You want to get your JavaScript to change both of these values.
    Code:
    function changeSrc(src){
    document.getElementById("movieParam").value = src;
    document.getElementById("movieEmbed").src = src
    }
    [FONT=Georgia]MinatureCookie.com[/FONT]
      Reply With Quote

  6. #6
    Member silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    189

    Wink 4 Sep 2010 @ 12.45

    Hey thanks very much for that, yes I know they will have to install a plugin but the site is a cd presentation for a software convention and basically some of my colleagues have messed up and given me video that doesn't have the quality to be compressed again (long story). Anyway thats excellent cheers guys
      Reply With Quote

Similar Threads

  1. Embedded secure webcam streaming
    By Lotusate in forum Imagery, Graphics & Typography
    Replies: 0
    Last Post: 16 Nov 2010, @ 04.29
  2. Play embedded video from button AS3
    By trixiemay in forum Imagery, Graphics & Typography
    Replies: 1
    Last Post: 19 Jun 2010, @ 09.23
  3. Play embedded sound in a WORD document (DOCX)?
    By cena2020 in forum Imagery, Graphics & Typography
    Replies: 0
    Last Post: 19 Jun 2010, @ 09.22
  4. Need Help Validating Embedded Code.
    By Wrams in forum HTML & CSS
    Replies: 6
    Last Post: 22 Oct 2009, @ 11.04

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
  •