ckplayer是一個國產網頁播放器,可以支持在線播放FLV和MP4視頻。
這個播放器類似於國外的JWplayer和FLOWplayer,可以通過官方提供的API接口進行定制。
ckplayer官網提供了一種基於IIS6的使用Mod-H264方法,在這里提供基於IIS7及以上版本的方法。
英文原文如下:
By default, IIS 7.0 is not installed on Windows Vista. You can install IIS by clicking Windows Features in Advanced Options under Programs in Control Panel.
When running Windows 32 bit:
- Create an App_Code folder, if you don't already have one, in c:\inetpub\wwwroot.
- Copy the Mod-H264-Streaming module (mod_h264_streaming.dll) into this directory (c:\inetpub\wwwroot\app_code).
When running Windows 64 bit:
- Enable 32 bit applications on win 64. See: IIS7 - Running 32-bit and 64-bit ASP.NET versions at the same time on different worker processes.
- Copy the Mod-H264-Streaming module (mod_h264_streaming.dll) into either (%windir%\syswow64\inetsrv) or (%windir%\system32\inetsrv) depending on your windows version.
我使用的是windows server 2008 r2 x64系統,因此要在IIS的應用程序池的高級選項中將啟用32位程序改為True。
Open up IIS Manager.
- Select 'MIME types'.
- Select 'Add'.
- Set 'File name extension' to '.mp4' and 'MIME type' to 'video/mp4'.
- Click 'OK'.
在MIME類型中添加MP4類型,這里要注意MP4不是使用video/mpeg而是video/mp4,這樣才能成功映射到ModH264Streaming模塊上。
- Select 'Modules'.
- Select 'Configure Native Modules'.
- Select 'Register'.
- Set 'Name' to 'ModH264Streaming'.
- Set 'Path' to the path where the mod_h264_streaming.dll is located.
- Click 'OK'.
- Click 'OK' again.
在模塊中注冊mod_h264_streaming.dll模塊。
- Select Handler Mappings.
- Select 'Add Module Mapping'.
- Set 'Request Path' to '*.mp4'.
- Set 'Module' to 'ModH264Streaming'.
- Set 'Name' to 'ModH264Streaming'.
- Click 'Request Restrictions'.
- Set 'Mappings' to 'Invoke handler only if request is mapped to file'.
- Set 'Verbs' to 'All verbs'.
- Set 'Access' to 'Scripts'. (Note to self: verify why this was previously 'Execute').
- Click 'OK'.
- Click 'OK' again.
處理程序映射中添加ModH264Streaming,之前網站上寫的是提供執行的訪問權限,但是在頁面調用中是通過javascript腳本調用的,因此用腳本的訪問權限,后來官網上也修正了這個錯誤。
下面給出一段調用代碼:
<html> <head> <script type="text/javascript" src="http://10.1.50.183:9000/jwplayer/jwplayer.js"></script> </head> <body> <br/><br/><br/><br/><br/> <div id="a1"></div> <script type="text/javascript" src="http://192.168.1.21:9000/ckplayer/ckplayer.js" charset="utf-8"></script> <script type="text/javascript"> var flashvars={ f:'http://192.168.1.21:9000/video/01.mp4', c:'0', h:'4', q:'start' }; CKobject.embedSWF('http://192.168.1.21:9000/ckplayer/ckplayer.swf','a1','ckplayer_a1','878','503',flashvars); </script> </body> </html>
其中flashvars的h和q參數表示開啟拖動,並且通過自動識別播放影片的后綴判斷是通過關鍵幀還是關鍵時間點進行拖動。