SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting a video object's width and height

    I have embeded a video like this:
    Code:
    <div class="videoDiv" id="showDis">
    <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="MediaPlayer1">  
    	<param name="url" value="http://mysite/myvideo.wmv"">  
    	<param name="src" value="http://mysite/myvideo.wmv"">  
    	<param name="showcontrols" value="true">  
    	<param name="autostart" value="true">  <!--[if !IE]>-->  
    	<object type="video/x-ms-wmv" data="http://mysite/myvideo.wmv"">    
    		<param name="src" value="http://mysite/myvideo.wmv"">    
    		<param name="autostart" value="true">    
    		<param name="controller" value="true">  
    	</object>  <!--<![endif]-->
    </object>
    </div>
    I would like to retrieve the video's width and height (resolution), for example: 640x480

    how can I do that via JavaScript?

    this is what I tried:
    Code:
    var objPlayer = document.MediaPlayer1;
    
    alert(objPlayer.offsetWidth);
    alert(objPlayer.width);
    
    
    alert(document.getElementById('showDis').style.width);
    alert(document.getElementById('showDis').style.offsetWidth);
    nothing gives me the real value.

    even looked here: http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx but couldn't find anything relevant

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isn't there anybody that can try to answer this?

  3. #3
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Is there anything that prevents you from knowing the width/height of the video beforehand?

    I'm sure you could use something like PHP-MP4info or getID3 to find the width/height on the server side if required.

    Additionally, if you're always expecting videos to be in a particular aspect ratio (e.g. 16:9) then you could simply specify a width/height that matches that aspect ratio and the browser should resize everything accordingly.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AussieJohn View Post
    Is there anything that prevents you from knowing the width/height of the video beforehand?

    I'm sure you could use something like PHP-MP4info or getID3 to find the width/height on the server side if required.

    Additionally, if you're always expecting videos to be in a particular aspect ratio (e.g. 16:9) then you could simply specify a width/height that matches that aspect ratio and the browser should resize everything accordingly.
    the videos are not hosted on my server and I have no way to know the width/height before hand.
    and no, i don't access to server side so I can't use PHP or Perl
    because of the above this is such a big problem and I can only rely on JavaScript+html+css


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
  •