根据访客的设备来显示视频的宽度和高度JS代码
有时候需要根据访客的设备来显示文章中的视频,现在用iPhone和iPad等的多了。下面是代码:
1 2 3 4 5 6 | <script type="text/javascript"> if (/(iPhone|iPad|iPod)/i.test(navigator.userAgent)) { document.write('<video width="480" height="320" src="http://v.youku.com/player/getRealM3U8/vid/<?php echo get_post_meta($post->ID, "_mcf_app-youku", true); ?>/type//video.m3u8" controls></video>'); }else{ document.write('<embed src="http://player.youku.com/player.php/sid/<?php echo get_post_meta($post->ID, "_mcf_app-youku", true); ?>/v.swf" allowFullScreen="true" quality="high" width="535" height="446" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>');} </script> |