我需要 flash swf 才能播放加密的flv / MP4 视频。我试过了.. HTTP://www.veryinteractivepeople.com/?p=525
这里我们要将flv文件放入swf并加密它。但我想分别加密flv / MP4并从主swf播放
我不是关于Action脚本3 的专家。但我会尝试。请告诉我一些解决方案。
答案 0 :(得分:1)
您需要使用空网络连接和网络流以“数据生成模式”准备视频。然后使用URLRequest加载加密的字节,解密它们,并将字节附加到网络流。
var nc = new NetConnection(null);
var ns = new NetStream(nc);
var encryptedBytes = .. get encrypted bytes from URLRequest ...
var decryptedBytes = .. your decryption function ..
ns.appendBytes(decryptedBytes);
var video = new Video();
addChild(video);
video.attachNetStream(ns);
ns.play(null);
答案 1 :(得分:0)
我试过这段代码.... http://www.veryinteractivepeople.com/?p=525
package
{
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.ByteArray;
[SWF(width="770", height="490", frameRate="31", backgroundColor="#FFFFFF")]
public class ProtectedSWF extends Sprite
{
//replace "encrypted.swf" to the name of your encrypted SWF file
[Embed(source="encrypted.swf", mimeType="application/octet-stream")]
private const EmbeddedSWF:Class;
//put your encryption key here
private static const KEY:String="WRITE_YOUR_OWN_CODE!";
public function ProtectedSWF()
{
var binaryData:ByteArray = new EmbeddedSWF();
if(binaryData.length != 0)
{
XOR(binaryData,KEY);
var animationLoader:Loader = new Loader();
animationLoader.loadBytes(binaryData);
addChild(animationLoader);
}
}
private static function XOR(binaryData:ByteArray, key:String):void{
var keyIndex:Number=0;
for(var i:Number=0;i<binaryData.length;i++){
binaryData[i]=binaryData[i]^key.charCodeAt(keyIndex);
keyIndex++;
if(keyIndex>=key.length)
keyIndex=0;
}
}
}
}