浏览器重新调整大小后,流体播放器不起作用

时间:2012-03-08 04:15:44

标签: mediaelement.js

我在宽度和高度标签中使用100%并且播放器在第一次打开时无论浏览器的大小如何都能正常工作但是只要我调整浏览器的大小,就不会再有任何控件工作了,它就是视频正在播放视频,屏幕变黑。我是否需要添加内容或者这只是一个错误?哦,是的,这发生在firefox 10.0.2。

这是我的代码:

<video width="100%" height="100%" id="player2" poster="media/Memphis-Beat_Ring-of-Fire.jpg" controls="controls" preload="none">
                    <source type="video/mp4" src="media/Memphis-Beat_Ring-of-Fire.mp4" />   
                </video>
                <script>
                    $('audio,video').mediaelementplayer({
                        success: function(player, node) {
                            //$('#' + node.id + '-mode').html('mode: ' + player.pluginType);
                        }
                    });
                </script>

1 个答案:

答案 0 :(得分:1)

这真让我恼火。我通过创建一个调整播放器大小的功能来解决它​​......

// For adjusting the player size on the fly
            var adjustVideoSize = function(me, el) {
                var width = $('.a_wrapper_that_is_fluid_width').width();
                var height = $('.a_wrapper_that_is_fluid_width').height();
                // min dimensions for the player
                if (width < 256) width = 256;
                if (height < 110) height = 110;
                // MediaElement methods for resizing
                me.setVideoSize(width, height);
                var player = me.player || el.player;
                player.setPlayerSize(width, height);
                player.setControlsSize();
            };

每次调整窗口大小时调用它。

相关问题