编译源代码修改jwplayer Build jwplayer source code

首先checkout jwplayer的源代码
地址:http://developer.longtailvideo.com/svn/trunk/fl5
编译jwplayer需要以下程序
* Flex SDK 4.1: http://sourceforge.net/adobe/flexsdk/wiki/Downloads/
* Ant 1.7.0: http://ant.apache.org/bindownload.cgi
* FlexUnit 4: http://opensource.adobe.com/wiki/display/flexunit/FlexUnit (for testing the player)
环境配置好之后需要修改配置文件
flexsdk = C:/Program Files/Adobe/Adobe Flash Builder 4.5/sdks/4.5.1
windows环境下需要更改execextension
execextension = .exe
根据flash player版本更改flexsdk.target
C:Program FilesAdobeAdobe Flash Builder 4.5sdks4.5.1frameworkslibsplayer10.2
这个是本机的player版本,所以
flexsdk.target = 10.2.0
配置文件修改完成之后就可以用ant来build了
控制台切换到build文件夹运行:ant -buildfile buildbuild.xml
输出:
Buildfile: E:Developmentjwplayersourcebuildbuild.xml
check-properties:
clean-release:
build-release-player:
release-swf:
build-swf:
[exec] ????????????????C:Program FilesAdobeAdobe Flash Builder 4.5sdks4.5.1frameworksflex-config.xml??
[exec] E:Developmentjwplayersourceplayer.swf??112357 ????
BUILD SUCCESSFUL
Total time: 4 seconds
如果你的电脑上装的是64位的java sdk的话,可能会报错
现在开始修改源代码
1、去掉左下角的jwplayer水印
找到com.longtailvideo.jwplayer.view里的View.as
找到protected function setupComponents()里的setupComponent(_logo, n++);注释掉即可
2、修改右键about的菜单项
找到com.longtailvideo.jwplayer.view里的RightclickMenu.as
修改function setAboutText()函数
about = new ContextMenuItem(‘About Sheng00 …’);
修改function aboutHandler(evt:ContextMenuEvent)函数
navigateToURL(new URLRequest(‘http://www.sheng00.com’), ‘_blank’);
 
然后ant -buildfile buildbuild.xml
生成的就是修改过的player了
以下是效果:
 

JW Player goes here




 

How to read VOD files from Amazon S3 on Standalone Wowza Server

From http://www.wmconsulting.info/read-vod-files-amazon-s3-standalone-wowza-server/
 
I’ll explain how to is possible read the files from Amazon S3 Storage but without using a EC2 instance.
For example your “localhost” or your Standalone Wowza server running on your own datacenter.
I did this for working on my local development environment, I’ll describe the steps for a Linux environment.
1- Download from this URL the 2 Jars, and copy this in /lib directories.
[download id=”5″]
[download id=”6″]
2- Create the MediaCache folder:

mkdir /mnt/mediacache

3- Insert into the conf/Server.xml this lines:

<ServerListeners>
<ServerListener>
<BaseClass>com.wowza.wms.plugin.amazonaws.ec2.mediacache.MediaCacheServerListenerAmazonEC2</BaseClass>
</ServerListener>
</ServerListeners>

4- Insert into the conf/vods3/Application.xml (create this first) this lines:

<MediaReader>
<Properties>
<Property>
<Name>randomAccessReaderClass</Name>
<Value>com.wowza.wms.plugin.amazonaws.ec2.mediacache.MediaCacheRandomAccessReaderAmazonEC2</Value>
</Property>
<Property>
<Name>bufferSeekIO</Name>
<Value>true</Value>
<Type>Boolean</Type>
</Property>
</Properties>
</MediaReader>

And in the end of the file, add this properties (I don’t know is needed this for read Public content):

<Properties>
<!-- Set these two properties to do S3 authentication -->
<Property>
<Name>awsAccessKeyId</Name>
<Value>KEY</Value>
</Property>
<Property>
<Name>awsSecretAccessKey</Name>
<Value>KEY</Value>
</Property>
</Properties>

5- Restart the Wowza Server and try reading from S3 Bucket.
The URL can be like this:
rtmp://localhost/vods3/_definst_/mp4:amazons3/wmconsulting.content/Extremists.m4v

Umbraco:get datatype values

Code:

@{
    //var prevalues = umbraco.library.GetPreValues(1235);
    var prevalues = umbraco.cms.businesslogic.datatype.PreValues.GetPreValues(1235);
}

@prevalues.ToString()

@if (prevalues.Count > 0) { for (int i=0;i@prevalue.Id:@prevalue.Value

} } }

output:

System.Collections.SortedList

81:国内

82:国外

83:资金

84:技术

85:人才

WordPress: modify the upload list of allowed file types

When you attempt to upload a file in WordPress that is not in the default list of acceptable file types, you will receive the following error: File type does not meet security guidelines. Try another. While there’s no admin-based tool for editing list of allowed file types, it’s not at all difficult to add your own or remove any existing.
Upload filetypes are checked by the function wp_check_filetype in wp-includes/functions.php. But we will add new file types to the file functions.php in our template due to upgrade WordPress.
Open your theme’s functions.php file and add this line somewhere between the <?php and ?>:
 

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the array
$existing_mimes['deb'] = 'application/x-deb';
// add as many as you like
// removing existing file types
unset( $existing_mimes['exe'] );
// add as many as you like
// and return the new full result
return $existing_mimes;
}

In this case I allowed upload .deb files and banned upload .exe files. List of MIME Types can be found here, or use google, if your file type is not in the list (e.g. deb or rpm file type).

IIS7 WordPress 中文 URL 解决方案

1、
使用插件 IIS Chinese Tag Permalink
2、
用 WordPress 写中文博客时 URL 中经常会包含中文字符,一般出现在 Tag 和分类的 URL 中。而 IIS7 对包含中文的 URL 支持有问题。这样的情况下访问如「http://sheng00.com/tag/软件」这样的 URL 就会发生 404 错误。
像 Godaddy 的 Windows 主机正是使用 IIS7 作为 Web 服务器的,在此空间上使用 WordPress 就会出现以上问题,虽然可以通过修改程序文件或者修改 Tag 和分类的别名为英文的方法来解决,但非常不实用。
下面介绍一种解决方法,只需要增加一个 PHP 文件,并修改一下 web.config 文件中的 Rewrite 规则即可,不需要修改程序文件。
新建一个“chineseurl.php”文件,内容如下:

<?php
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
// IIS Mod-Rewrite
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
} else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
// IIS Isapi_Rewrite
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
// Use ORIG_PATH_INFO if there is no PATH_INFO
(!isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) && ($_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']);
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if (isset($_SERVER['PATH_INFO'])) {
($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME']) ? ($_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']) : ($_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']);
}
// Append the query string if it exists and isn't null
(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) && ($_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']);
}
require("index.php");
?>

修改 web.config 文件内容如下:

?<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
 <rewrite>
 <rules>
 <rule name="cnUrl" stopProcessing="true">
 <match url="^(tag|category)/(.*)$" />
 <action type="Rewrite" url="cnurl.php" />
 </rule>
 <rule name="WordPress" patternSyntax="Wildcard">
 <match url="*" />
 <conditions>
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php" />
 </rule>
 </rules>
 </rewrite>
 </system.webServer>
</configuration>

以上两个文件都存放在 WordPress 的安装目录。
如果 WordPress 不是装在根目录,则需要更改“<match url=”^(tag|category)/(.*)$” />”为“<match url=”^安装目录/(tag|category)/(.*)$” />”。如果在固定链接设置里把默认的标签前缀和分类目录前缀(tag 和 category)改了,则更改这句里的对应内容即可。
此文适用于 WordPress 2.9,2.9以下版本应该也可以适用,但笔者没有测试过。

js验证代码

1.JS判断是否是邮编

<script>
function isPostalCode(s)
{
//var patrn=/^[a-zA-Z0-9]{3,12}$/;
var patrn=/^[a-zA-Z0-9 ]{3,12}$/;
if (!patrn.exec(s)) return false
return true
}
var a = "315400";
alert(a+"是否合法!");
alert(isPostalCode(a));
a = "ab";
alert(a+"是否合法!");
alert(isPostalCode(a));
</script>

2.JS判断电话传真号码是否有效

<script>
function isTel(s)
{
var patrn=/^[+]{0,1}(d){1,3}[ ]?([-]?((d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
var a = "0574-56158888";
alert(a+"是否合法!");
alert(isTel(a));
a = "123456a";
alert(a+"是否合法!");
alert(isTel(a));
</script>

3.js正则判断:只能输入5-20个以字母开头、可带数字、“_”、“.”的字符串

<script>
function isRegisterUserName(s)
{
var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;
if (!patrn.exec(s)) return false
return true
}
var a = "abc";
alert(a+"是否合法!");
alert(isRegisterUserName(a));
a = "abcdef";
alert(a+"是否合法!");
alert(isRegisterUserName(a));
</script>

4.判断身份证号码的JS函数

<script type="text/javascript">
var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
function cidInfo(sId)
{
var iSum=0
var info=""
if(!/^d{17}(d|x)$/i.test(sId))
{
return false;
}
sId=sId.replace(/x$/i,"a");
if(aCity[parseInt(sId.substr(0,2))]==null)
{
return false;
}
sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
var d=new Date(sBirthday.replace(/-/g,"/"))
if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
{
return false;
}
for(var i = 17;i>=0;i --)
{
iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
}
if(iSum%11!=1)
{
return false;
}
return true;
}
alert(cidInfo("3432423432423432"));
</script>

5.验证日期是否合法的JS函数

<script type="text/javascript">
function isDateFormat(txt){ //是否为合法的日期格式:YYYY-MM-DD
if(txt==null || txt == ""){return false;}
else{
var regex = /[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}/;
if( regex.test(txt) ){
var noArr = txt.split("-");
var year = eval(noArr[0]);
var month = eval(noArr[1]);
var day = eval(noArr[2]);
if ( year < 1 || month < 1 || month > 12 || day < 1 || day > 31) {return false;}
if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30){return false;}
if (month == 2){
if ((year % 4 != 0) && day > 29) { return false;}
if (year % 4 == 0){
if(year % 100 == 0 && year % 400 != 0 && day > 29){return false;}
else if (day > 28){ return false;}
}
}
return true;
}else{return false;}
}
}
alert("2008-05-11是日期吗?答:"+isDateFormat("2008-05-11"));
</script>

6.验证手机号码固定电话号码的JS函数

<script type="text/javascript">
function isPhoneNum(txt){ //检测是否为电话号码(固定电话或手机)
return isPhone(txt)||isMobile(txt);
}
function isPhone(txt){//检测是否为固定电话号码
if(txt == null || txt == ""){return false;}
else{
var regex = /[0-9]{1}[0-9]{2,3}-[1-9]{1}[0-9]{5,8}/;
return regex.test(txt);
}
}
function isMobile(txt){//检测是否为手机号码
if(txt == null || txt == ""){return false;}
else{
var regex = /13[0-9]{9}/;
return regex.test(txt);
}
}
alert(isPhone("0574-56157573"));
alert(isMobile("0574-56157574"));
alert(isMobile("13956122541"));
</script>

7.控制文本框输入长度的例子

<script>
function test()
{
if(a.value.length>10){
alert("不能超过10个字符");
a.focus();
}
else
top.location.href="http://www.baidu.com";
}
</script>
<input type="text" name=a><input type="button" value="测试" onclick="test();">

8.JS判断中文的正则表达式

<script>
function strChinese(str){
var pattern = /[^u4E00-u9FA5]/;
return !pattern.test(str);
}
alert(strChinese("中文"))
alert(strChinese("abc"))
alert(strChinese("中文Abc"))
</script>

9.验证email邮箱地址的js

<script type="text/javascript">
function isEmail(str){
res = /^[0-9a-zA-Z_-.]+@[0-9a-zA-Z_-]+(.[0-9a-zA-Z_-]+)*$/;
var re = new RegExp(res);
return !(str.match(re) == null);
}
alert(isEmail("abc.com"));
alert(isEmail(""));
</script>

JS operations on JSON summary

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式。同时,JSON是 JavaScript 原生格式,这意味着在 JavaScript 中处理 JSON数据不须要任何特殊的 API 或工具包。
本文主要是对JS操作JSON的要领做下总结。
在JSON中,有两种结构:对象和数组。

  1. 一个对象以{(左括号)开始,}(右括号)结束。每个“名称”后跟一个:(冒号);“‘名称/值’ 对”之间运用 ,(逗号)分隔。 名称用引号括起来;值如果是字符串则必须用括号,数值型则不须要。例如:
    var o = {
      "xlid": "cxh",
      "xldigitid": 123456,
      "topscore": 2000,
      "topplaytime": "2009-08-20"
    }
    
  2. 数组是值(value)的有序集合。一个数组以[(左中括号)开始,](右中括号)结束。值之间运用 ,(逗号)分隔。例如:
    var jsonranklist = [{
      "xlid": "cxh",
      "xldigitid": 123456,
      "topscore": 2000,
      "topplaytime": "2009-08-20"
    }, {
      "xlid": "zd",
      "xldigitid": 123456,
      "topscore": 1500,
      "topplaytime": "2009-11-20"
    }];
    

为了方便地处理JSON数据,JSON提供了json.js包,下载地址:http://www.json.org/json.js
在数据传输流程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键。例如:

  • JSON字符串:
    var str1 = '{ "name": "cxh", "sex": "man" }';
    
  • JSON对象:
    var str2 = { "name": "cxh", "sex": "man" };
    
  1. JSON字符串转换为JSON对象,要运用上面的str1,必须运用下面的要领先转化为JSON对象:
    var obj = eval('(' + str + ')');//由JSON字符串转换为JSON对象
    

    或者

    var obj = str.parseJSON(); //由JSON字符串转换为JSON对象
    

    或者

    var obj = JSON.parse(str); //由JSON字符串转换为JSON对象
    

    然后,就可以这样读取:

    Alert(obj.name);
    Alert(obj.sex);
    

    特别留心:如果obj本来就是一个JSON对象,那么运用 eval()函数转换后(哪怕是多次转换)还是JSON对象,但是运用 parseJSON()函数处理后会有疑问(抛出语法异常)。

  2. 可以运用 toJSONString()或者全局要领 JSON.stringify()将JSON对象转化为JSON字符串。
    例如:

    var last=obj.toJSONString(); //将JSON对象转化为JSON字符
    

    或者

    var last=JSON.stringify(obj); //将JSON对象转化为JSON字符
    
    alert(last);
    

    留心:上面的多个要领中,除了eval()函数是js自带的之外,其他的多个要领都来自json.js包。新版本的 JSON 修改了 API,将 JSON.stringify()JSON.parse() 两个要领都注入到了 Javascript 的内建对象里面,前者变成了 Object.toJSONString(),而后者变成了 String.parseJSON()。如果提示找不到toJSONString()parseJSON()要领,则说明您的json包版本太低。