How to set width and height to jPlayer

Tushar Ahirrao picture Tushar Ahirrao · Feb 12, 2012 · Viewed 16.2k times · Source

I am using jPlayer library but i don't know how to set width and height

My code is :

 $("#jquery_jplayer_1").jPlayer({
                    ready: function(){
                        $(this).jPlayer("setMedia", {
                            m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v"
                        }).jPlayer("play");
                    },
                    ended: function(event){
                        // $(this).jPlayer("play");
                    },
                    swfPath: "../../common/assets/jplayer/js",
                    supplied: "m4v"

                });

Please help me.

Answer

Adeerlike picture Adeerlike · Feb 12, 2012

Untested, I think your code should look something like this:

 $("#jquery_jplayer_1").jPlayer({
                    ready: function(){
                        $(this).jPlayer("setMedia", {
                            m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v"
                        }).jPlayer("play");
                    },
                    ended: function(){
                         $(this).jPlayer("play");
                    },
                    swfPath: "../../common/assets/jplayer/js",
                    supplied: "m4v",
                    size: {
                         width: "400px",
                         height: "30px"
                    }
                });

I noticed that you were trying to loop the file? I changed the function call since it doesn't seem like you need the (event).

You should read this: http://jplayer.org/latest/developer-guide/#jPlayer-size
The sizes change according to the file types given.