detail.html 2.07 KB
<script type="text/javascript" charset="utf-8">
    //详情页面JS
    seajs.use(['js/channel/detail', 'js/public'], function(detail) {
            if (detail) {
                detail.init();
                detail.videoMiniPlayer();

                // IPAD上面的视频处理
                if (navigator.userAgent.indexOf("iPad") !== -1) {
                    // 封面视频播放器替换为H5的VIDEO标签
                    if (!!$(".video-wrap").find("object").size()) {
                        $(".video-wrap").find("object").hide();
                        $("#video-ipad").show();
                    }
                    // 隐藏老格式的手机视频
                    if (!!$('.content-mobile-flash').size()) {
                        $('.content-mobile-flash').hide();
                    }
                    // 内容中视频播放器替换为H5的VIDEO标签
                    if (!!$(".text-body").find("object").size()) {
                        var defaultCover = $(".detail-body").attr("cover-url");
                        var playHref = "",
                            videoUrl = "",
                            videoCover = "",
                            videoHtml = "";
                        $(".text-body").find("object").each(function() {
                            playHref = $(this).find('embed').attr('src');
                            videoUrl = tools.request('url', playHref);
                            videoCover = tools.request('coverpic', playHref);
                            if (videoCover === "") {
                                videoCover = defaultCover;
                            }
                            videoCover = videoCover.replace(/%3A/g, ':').replace(/%2F/g, '/');
                            videoHtml = '<video controls="controls" preload="auto" width="700px" height="394px" poster="' + videoCover + '">' + '<source src="' + videoUrl + '" type="video/mp4">' + '</video>';
                            $(this).replaceWith(videoHtml);
                        });
                    }
                }
            }


        });
</script>