Reputation: 41
I need to make flash swf for play encrypted flv/MP4 videos. I tried this.. HTTP://www.veryinteractivepeople.com/?p=525
Here we want to put flv file in to the swf and encrypt it. But I want to encrypt flv/MP4 separately and play from main swf
I am not a expert about Action script 3. But I try. Please tell me some solution for this.
Upvotes: 0
Views: 805
Reputation: 41
I tried this code.... 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;
}
}
}
}
Upvotes: 0
Reputation: 74939
You'll need to use a null net connection and net stream to prepare a video in "data generation mode". Then load encrypted bytes with a URLRequest, decrypt them, and append the bytes to a net stream.
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);
Upvotes: 1