zoukankan      html  css  js  c++  java
  • ucenter home 视频增加缩略图

    注:在http://www.discuz.net/thread-1465174-1-1.html上面修改更新,增加56.com。可在这里下载最新版本,http://pan.baidu.com/netdisk/singlepublic?fid=156737_3291021664

    插件说明

    功能:

    将从youku,tudou,ku6,mofile,56等视频站分享的视频以缩略图显示

    环境支持:

    空间需支持file_get_contents函数。默认allow_url_fopen开启的时候该函数有效。

    allow_url_fopen开启方法:

    php.ini文件中将allow_url_fopen如下设置:(大部分空间都是开启的)

    allow_url_fopen = on

    安装说明

    1、需要更改的文件

    source/cp_share.php

    source/script_common.js(支持土豆视频需要修改此文件)

    template/你自己的风格目录/space_feed_li.htm(默认情况下此文件在默认风格目录即default文件夹下)

    template/你自己的风格目录/space_share_li.htm(默认情况下此文件在默认风格目录即default文件夹下)

    2、增加的文件

    image/movie_icon.png(视频缩略图上显示的播放按钮)

    image/noimg.gif(没有视频缩略图时的显示图标)

    3、安装步骤

    3.1打开cp_share.php(默认408行)

    if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn)$/i", $parseLink['host'], $hosts)) {

      $flashvar = getflash($link, $hosts[1]);

      if(!empty($flashvar)) {

        $arr['title_template'] = cplang('share_video');

        $type = 'video';

        $arr['body_data']['flashvar'] = $flashvar;

        $arr['body_data']['host'] = $hosts[1];

     }

    }

    将上面代码用以下代码替换

    if(preg_match("/(youku.com|youtube.com|56.com|ku6.com|sohu.com|mofile.com|sina.com.cn|tudou.com)$/i", $parseLink['host'], $hosts)) {

      $flashvar = getflash($link, $hosts[1]);

      if(!empty($flashvar)) {

        $flashimg = getflashimg($flashvar, $hosts[1]);

        $arr['title_template'] = cplang('share_video');

       $type = 'video';

       $arr['body_data']['flashvar'] = $flashvar;

       $arr['body_data']['host'] = $hosts[1];

       if(!empty($flashimg)){

         $arr['image'] = $flashimg;

       }

    }

    }

    3.2再查找function getflash($link, $host)(默认在490行)

    function getflash($link, $host) {

    $return = '';

    if('youku.com' == $host) {

    // http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html

    preg_match_all("/id\_(\w+)[=.]/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('ku6.com' == $host) {

    // http://v.ku6.com/show/bjbJKPEex097wVtC.html

    preg_match_all("/\/([\w\-]+)\.html/", $link, $matches);

    if(1 > preg_match("/\/index_([\w\-]+)\.html/", $link) && !empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('youtube.com' == $host) {

    // http://tw.youtube.com/watch?v=hwHhRcRDAN0

    preg_match_all("/v\=([\w\-]+)/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('5show.com' == $host) {

    // http://www.5show.com/show/show/160944.shtml

    preg_match_all("/\/(\d+)\.shtml/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('mofile.com' == $host) {

    // http://tv.mofile.com/PPU3NTYW/

    preg_match_all("/\/(\w+)\/*$/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('sina.com.cn' == $host) {

    // http://you.video.sina.com.cn/b/16776316-1338697621.html

    preg_match_all("/\/(\d+)-(\d+)\.html/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    } elseif('sohu.com' == $host) {

    // http://v.blog.sohu.com/u/vw/1785928

    preg_match_all("/\/(\d+)\/*$/", $link, $matches);

    if(!empty($matches[1][0])) {

    $return = $matches[1][0];

    }

    }

    return $return;

    }

    将上面的代码用下面的替换

    /**

     * 匹配视频序号

     * 

     * @param string $link 视频链接

     * @param string $host 网站域名

     * @return string $flvid 视频序号

     */

    function getflash($link, $host) {

    $flvid = $preg = '';

    if('youku.com' == $host) {

    //http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html

    $preg = '/id\_(\w+)[=.]/';

    } elseif('ku6.com' == $host) {

    // http://v.ku6.com/show/bjbJKPEex097wVtC.html

    $preg = '/show\/(.+?)\.html/';

    } elseif('youtube.com' == $host) {

    // http://tw.youtube.com/watch?v=hwHhRcRDAN0

    $preg = '/v\=([\w\-]+)/';

    } elseif('sina.com.cn' == $host) {

    // http://video.sina.com.cn/v/b/16776316-1338697621.html

    $preg = '/\/(\d+)-(\d+)\.html/';

    } elseif('sohu.com' == $host) {

    // http://v.blog.sohu.com/u/vw/1785928

    $preg = '/\/(\d+)\/*$/';

    } elseif('tudou.com' == $host) {

    // http://www.tudou.com/programs/view/oOrUqgezkOc/

    $preg = '/\/([\w\-]+)\/*$/';

            } elseif ('56.com' == $host) {

    // http://www.56.com/w86/play_album-aid-9869018_vid-Njc4MTk1MTY.html

    $preg = (strpos($link, 'play_album') === false) ? '/http:\/\/www.56.com\/\S+\/([^\/]+).html/i' :

    '/http:\/\/www.56.com\/\S+\/play_album-aid-(\d+)_vid-(.+?).html/i';

    }

    // 匹配视频序号

    if ($preg && preg_match($preg, $link, $matches))

    $flvid = $matches[1];

        

    return $flvid;

    }

    /**

     * 获取视频图片地址

     *

     * @param string $flashvar 视频序号

     * @param string $host 域名地址

     * @return string $imgurl 视频图片地址

     */

    function getflashimg($flashvar, $host) {

    // 图片地址,视频地址

    $imgurl = $url = '';

    if('tudou.com' == $host) {

    // http://www.tudou.com/programs/view/oOrUqgezkOc/

    $url = 'http://www.tudou.com/programs/view/'. $flashvar;

    $preg_img = "/pic\s\=\s'(.+?)'\s,lpic/";

    } elseif('youku.com' == $host) {

    // 'http://v.youku.com/v_show/id_XMzkxNDUzMDU2.html'

    $url = 'http://v.youku.com/player/getPlayList/VideoIDS/'.$flashvar;

    $preg_img = '/"logo":"(.+?)"/';

    } elseif ('sina.com.cn' == $host) {

    // http://video.sina.com.cn/v/b/16776316-1338697621.html

    $url = 'http://interface.video.sina.com.cn/interface/common/getVideoImage.php?vid='.$flashvar;

    $preg_img = '/imgurl\=(.+?)/U';

    } elseif('ku6.com' == $host) {

    // http://v.ku6.com/show/dcTU2QX6sb5QXz-C_30CDA...html

    $url = 'http://vo.ku6.com/fetchVideo4Player/1/'.$flashvar.'.html';

    $preg_img = '/\"picpath\":\"(.+?)\"/i';

    } elseif ('sohu.com' == $host) {

    // http://my.tv.sohu.com/u/vw/13706596

    $url = 'http://v.blog.sohu.com/videinfo.jhtml?m=view&id='.$flashvar.'&outType=3';

    $preg_img = '/"cusCoverURL":"(.+?)"/';

    } elseif ('56.com' == $host) {

    // http://www.56.com/w86/play_album-aid-9869018_vid-Njc4MTk1MTY.html

    $url = 'http://vxml.56.com/json/'.str_replace('v_', '', $flashvar).'/?src=out';

    $preg_img = '/\"img\":\"(.+?)\"/i';

    }

    // 获取图片地址

    if ($url) {

    $content = file_get_contents($url);

    if ($content && preg_match($preg_img, $content, $matches))

    {

    $imgurl = trim($matches[1]);

    // 去除反斜杠

    if ('youku.com' == $host) 

    $imgurl = stripslashes($imgurl);

    elseif ('ku6.com' == $host)

    $imgurl = str_replace(array('\u003a', '\u002e'), array(':', '.'), $imgurl);

    }

    }

    return $imgurl;

    }

    3.3

    打开script_common.js(默认在342行)

    在'mofile.com' : 'http://tv.mofile.com/cn/xplayer.swf?v=FLASHVAR',下面添加下面的代码(支持土豆,56)

    'tudou.com' : 'http://www.tudou.com/v/FLASHVAR',

    '56.com' : 'http://player.56.com/v_FLASHVAR.swf',

    3.4

    再查找hideObj.style.cursor = 'pointer';

    在其下面加入下面代码:

    //add

    if('music' != host&&'flash' != host){

                    $('icon_id_'+shareid).style.display='none';

                    $('media_id_'+shareid).style.display='none';

                   }

    //end

    3.5

    查找obj.style.display = '';(有两处,在第一处下面)

    在其下面添加代码:

    //add

    if('music' != host&&'flash' != host){

                    $('icon_id_'+shareid).style.display='';

                    $('media_id_'+shareid).style.display='';

                  }

    //end

    3.6

    打开space_feed_li.htm

    查找:

    <!--{if $value['image_1']}-->

    修改为:

    <!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->

    查找:(在47行)

    <div class="media">

    <img src="image/vd.gif" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />

    </div>

    修改为:

    <div class="media">

             <div class="movie_app">

               <img id=icon_id_$value[feedid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />

    <img id="media_id_$value[feedid]" class=movie_pic src="<!--{if !empty($value['image_1'])}-->$value[image_1]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />

     </div>

    </div>

    3.7

    打开space_share_li.htm

    查找:(默认15行附近)

    <!--{if $value['image']}-->

    修改为:

    <!--{if $value['image'] && 'video'!=$value['type']}-->

    查找:(默认22行附近)

    <!--{if 'video' == $value['type']}-->

    <div class="media">

    <img src="image/vd.gif" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />

    </div>

    修改为:

    <!--{if 'video' == $value['type']}-->

    <div class="media">

    <div class="movie_app">

    <img id=icon_id_$value[sid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;">

    <img id="media_id_$value[sid]" class=movie_pic src="<!--{if !empty($value['image'])}-->$value[image]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />

    </div>

    </div>

    3.8

    打开default/style.css(缩略图上显示播放按钮需要修改此文件)

    在文件末尾加上下面的代码:

    /**********************************************Vedio_img***/

    .movie_none{display:none;position:relative}

    .movie_app .movie_pic{128px;height:96px;}

    * html .movie_pic{ expression(this.width > 120 ? 120 : true);  display:block}

    .media{display:block;POSITION: relative;zoom:1}

    .movie_app{}

    .movie_app img {margin-left:5px;margin-top:5px; max- 130px; max-height: 96px;}

    * html .movie_app img { expression(this.width > 200 && this.width/this.height > 2 ? 200 : true); height: expression(this.height > 100 && this.width/this.height < 2 ? 200 : true); display:block}

    .movie_app .movie_icon {

    21px;height:21px;BACKGROUND: none transparent scroll repeat 0% 0%; FILTER: alpha(opacity=70); left: 55px; BORDER-TOP-STYLE: none! important; BOTTOM: 35px; BORDER-RIGHT-STYLE: none! important; BORDER-LEFT-STYLE: none! important; POSITION: absolute; BORDER-BOTTOM-STYLE: none! important; opacity: 0.9

    }

  • 相关阅读:
    java基础知识要点总结之几个重要关键字(关于static、this、final、)
    网上大篇幅的坑人的struts2入门案例
    oc4j(oracle container for j2EE)使用笔记一
    清空数据库中某个表的两种操作
    MyEclipse下将应用部署到tomcat严重: Error initializing endpoint java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    jsp----错误页设置
    jsp设置MIME类型
    jsp输出显示表格
    jsp输出方式
    Linux操作
  • 原文地址:https://www.cnblogs.com/tdalcn/p/2587504.html
Copyright © 2011-2022 走看看