[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]discuz手机播放视频[/p][p=null, 2, left][color=rgb(0, 0, 0)]部落找到了一个六月_手机视频播放免费版,大家可以试试看,介绍地址是:由此直达.[/p][p=null, 2, left][color=rgb(0, 0, 0)]优酷 土豆 56 酷六视频等视频资源在手机端点击既能及时观看.[/p][p=null, 2, left][color=rgb(0, 0, 0)]当然,还有其它的,自己可以找一下.[/p][p=null, 2, left][color=rgb(0, 0, 0)]如何让discuz论坛手机版也能播放网络视频?[/p][p=null, 2, left][color=rgb(0, 0, 0)]这里部落列出自己收集的几个方法:[/p][p=null, 2, left][color=rgb(0, 0, 0)]一.[/p][p=null, 2, left][color=rgb(0, 0, 0)]如果手机安装了flash播放器,可以使用下面的方法.[/p][p=null, 2, left][color=rgb(0, 0, 0)]首先我们打开source/function/function_discuzcode.php,然后查找:[/p]$message = preg_replace(\"/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is\", \"[media]\\4[/media]\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]修改为:[/p]$message = preg_replace(\"/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/\", \"<embed src='\\4' allowFullScreen='true' quality='high' width='260' height='150' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash'></embed>\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]保存后手机版的discuz 也能播放网络视频了.[/p][p=null, 2, left][color=rgb(0, 0, 0)]部落的线报论坛成功操作后如下图:[/p][p=null, 2, left][color=rgb(0, 0, 0)]
[/p][p=null, 2, left][color=rgb(0, 0, 0)]二.[/p][p=null, 2, left][color=rgb(0, 0, 0)]另外一种方法实现,在版块里禁用discuz代码,采用html代码!然后在编辑器里用如杲方式调用,这样手机就可以访问了.[/p][p=null, 2, left][color=rgb(0, 0, 0)]
[/p][p=null, 2, left][color=rgb(0, 0, 0)]论坛板块和用户权限打开html支持,发帖选项,纯文本,html(点开附加选项才可以选html),然后插入以下代码,视频id XNzEwMzEyNDk2 换成自己的,可以在优酷网视频网址里看到.[/p][p=null, 2, left][color=rgb(0, 0, 0)]这个方法部落没有测试,自测吧.[/p][p=null, 2, left][color=rgb(0, 0, 0)]三.[/p][p=null, 2, left][color=rgb(0, 0, 0)]手机版支持播放外链视频的方法,可支持触屏版,也可支持标准版.[/p][p=null, 2, left][color=rgb(0, 0, 0)]首先找到discuz的ubb代码解析文件(source/function/function_discuzcode.PHP),在大约199行的时候可以看到,如果用户打开的是手机版,那么[media]、、[flash=314,256,1]这3个标签都会被放弃解析,统一输出成[media]XXXXX[/media]这种格式.[/p][p=null, 2, left][color=rgb(0, 0, 0)]首先改动[media]标签的解析,将第200行的代码:这个和第一部的基本一样,只是后面加入解析代码.[/p]$message = preg_replace(\"/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is\", \"[media]\\2[/media]\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]修改为:[/p]$message = preg_replace(\"/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is\", \"<p class=\\"hm\\" onclick=\\"openVideo(this,'\\2')\\"><img src=\\"static/image/common/vd.gif\\" /></p>\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]在来改动[flash=314,256,1]标签的解析,将205行的代码:[/p]$message = preg_replace(\"/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is\", \"[media]\\4[/media]\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]修改为:[/p]$message = preg_replace(\"/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is\", \"<p class=\\"hm\\" onclick=\\"openVideo(this,'\\4')\\"><img src=\\"static/image/common/vd.gif\\" /></p>\", $message);
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]然后修改模版文件(template/default/touch/forum/viewthread.htm),在任意一个JS标签中加入解析视频的代码:[/p]function openVideo(a,b) {
$(a).html('<img src=\"static/image/mobile/images/icon_load.gif\" />');
var w = $(a).width();
var h = w * 0.85;
if(/youku/.test(b)){ //解析优酷
b = b.match(/id_(.*?)\.html|sid\/(.*?)\/v/);
b = 'http://player.youku.com/embed/' + (b[1] ? b[1] : b[2]);
}else if(/bilibili|acg\.tv/.test(b)){ //解析B站
b = b.match(/o\/av(.*?)\/|aid=(.*?)&/);
b = 'http://www.bilibili.com/video/av' + (b[1] ? b[1] : b[2]);
}else{
$(a).html('不支持此视频地址显示:' + b);
return;
}
$(a).append('<iframe width=0 height=0 src=\"' + b + '\" scrolling=no frameborder=0 allowfullscreen></iframe>');
$(a).children('iframe').load(function(){
$(a).children('img').remove();
$(a).children('iframe').css({'width':w,'height':h});
})
}
[p=null, 2, left][color=rgb(0, 0, 0)] [/p][p=null, 2, left][color=rgb(0, 0, 0)]可以用手机打开一个有视频的帖子看看效果了.[/p][p=null, 2, left][color=rgb(0, 0, 0)]这里只写了优酷和B站的解析,其他视频地址的解析暂时没有写,不过有了上面的JS做参考很简单就可以写出支持其他站的视频外链。其原理就是,按照视频URL匹配出VID然后组成可以加载出HTML5播放器的URL在通过iframe框架加载页面就行了.[/p][p=null, 2, left][color=rgb(0, 0, 0)]小结[/p][p=null, 2, left][color=rgb(0, 0, 0)]discuz论坛手机版也能播放网络视频,如果要等官方的支持,估计还得有些时间.部落目前自己使用的就是第一种方法.[/p]