0

i had embeded a media player in my page.

And i had detect browser solution as to resize the width and height of the player.

but i found that it doesn;t work in Firefox.

pls advise. thanks.

<object id="player" width="300" height="400" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">

    <PARAM NAME="stretchToFit" Value="1"> 
    ...................
    <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" name="MediaPlayer" src="http://xxxxxxxxxxxxxx" 
    showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="0" showdisplay="0" showstatusbar="1" showgotobar="0" 
    showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowchangedisplaysize="0" 
    allowscan="0" enablecontextmenu="0" clicktoplay="0" width="300" height="400" stretchToFit="1"></embed>

jquery/javascript code as follow:

jQuery(document).ready(function() {

        var height;
        var width;
        var paddingtop;

        if (screen.width <= 1280) {
            width = ($(window).width() - 20);
            height = width / 2;
            paddtingtop = 4;

        }
        else if ((screen.width > 1280) && (screen.width < 1920)) {
            width = ($(window).width() - 20);
            height = width / 1.7;
            paddtingtop = 7;

        }
        else {
            width = ($(window).width() - 20);
            height = width / 1.7;
            paddtingtop = 7;

        }
        $("#player").css('width', width);
        $("#player").css('height', height);
        $("#player").css('padding-top', paddtingtop);

    });
Joe Yan
  • 2,025
  • 8
  • 43
  • 62

1 Answers1

0

For the width you don't need javascript to make it the window width less 20px you can just use css. Here is a quick example: http://jsfiddle.net/m5GaA/

You can find a more thorough css answer here: xHTML/CSS: How to make inner div get 100% width minus another div width

As well as the last else mentioned already, the (screen.width > 1280) in your second if is superflous, the condition is already guaranteed by the previous if.

You are missing a closing tag is this missing on your page as well? This could be the cause.

I can't see why else that won't work, but the html/css is probably the root cause of the problem, try and provide a demo if you still need to.

The jsfiddle code:

#HTML
<div id=wrapper>
  <div id=inner>
    content must be present
  </div>
</div>​

#CSS
#wrapper {
    overflow:hidden;
    background-color:red;         
    padding: 0px 10px 0px 10px;
    width:100%;
    height:100%;    
}

#inner {
    float:left;
    background-color:blue;       
    width:100%;
    height:100%;
}
Community
  • 1
  • 1
Ed Kirk
  • 583
  • 1
  • 4
  • 9