通过浏览器自动安装 DRM 许可证的代码 (Windows Media Player) - ○白子○ 的Blog

通过浏览器自动安装 DRM 许可证的代码 (Windows Media Player)

[ 2008-03-27 03:37:50 | Author: seaboat ]
Font Size: Large | Medium | Small
Windows 媒体播放器下的 DRM 的版权保护机制,用 JavaScript 控制 HTML 内嵌对象来实现。
为了对不同的文件安装不同的许可证,需要动态生成相应的代码,以下是我的一个土办法(Perl):
# 这儿是许可证
$licenseID = "......";

# 页面载入时的JavaScript代码
my $add_js = qq|
<script Language="JavaScript">
 function StoreLicense() {
 GetLicenseObj.StoreLicense('<LICENSERESPONSE>$licenseID</LICENSERESPONSE>');
 }

 try{
 window.addEventListener('load', StoreLicense, true);
 } catch(ex) {
 window.attachEvent('onload', StoreLicense);
 }
</script>
|;

# DRM对象的HTML代码
my $add_html = qq|
<object id="GetLicenseObj" classid="clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062" name="GetLicenseObj" viewastext>
 <embed mayscript type="application/x-drm-x2" hidden="true">
 </embed>
</object>
|;

# 打开 HTML 文件,插入以上代码并送出
open(TMP, $html_path) or die "Can not open temp file: $html_path";
print "Content-type: text/html\n\n";
while(<TMP>) {
 
 if( /[\s\t]*<\/head/i ) {
 print $add_js;
 } elsif( /[\s\t]*<\/body/i ) {
 print $add_html;
 }
 print $_;
}

close(TMP);
以上方法,仅供参考,切勿照抄。
Comments Feed Comments Feed: http://www6.webng.com/seaboat/feed.asp?q=comment&id=704

View Mode: Show All | Comments: 1 | Trackbacks: 0 | Toggle Order | Views: 453
Quote Pol39*
[ 2009-10-22 13:19:04 ]
What I am missing however, is the integration with Web Analytics reporting tools. ,

Post Comment
Smilies
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
Enable UBB Codes
Auto Convert URL
Show Smilies
Hidden Comment
Username:   Password: