Flash Movies and ActionScript - Stop the video fro

2019-08-13 08:22发布

I posted a question on superuser which seems to have a code related answer, so here it goes. I have a problem; I need to share videos online, but need to find a way to either completely stop, or at least make it hard for people to download them and view them online. I'm aware that if it was possible, Hollywood would have done it already, but I have an idea...

Some years ago I stumbled across a video on newgrounds.com, a site for flash animators to post their content for users to rate, feedback and comment on, a place where I spent hours downloading videos to play them at school (oh the irony...), but I remember one video was diferent. After downloading, and opening the .swf file, it stoped playback and displayed a frame that said "Sorry, this animation was made to be viewed on newgrounds.com. You can find it there anytime!". I was mad at the time, but now it gave me an idea...

Is there some way I can get the animation to check the current location/directory of the file being played, so that if it finds out it's being played from a physical computer instead of the server it was meant to be played from, it stops playback completely???

2条回答
女痞
2楼-- · 2019-08-13 09:10

You can get the URL that the SWF is playing on (generally the page's location, if embedded in HTML) through stage.loaderInfo.url, I believe. So you can just check that against the URL of your site.

This can be fooled, though. I could set up a vhost on my machine that could probably mimic your site's address in the loaderInfo which would allow me to play it. You'd be better off using a form of DRM than this. DRM is, in general, much more difficult to crack than faking a URL.

查看更多
狗以群分
3楼-- · 2019-08-13 09:25

This functionality is called "Site locking". You can google that term for more information. Here is a link to the AS3 Games Blog "Emenuelle Ferronato" with a tutorial on how to sitelock a file.

http://www.emanueleferonato.com/2008/03/10/how-to-sitelock-a-flash-movie/

The blog gives the code in AS2, so I updated it below using AS3. This code needs to have access to the stage, and you need to call "sitelock(urls_allowed)" at the point the lock check should be perforemed.

urls_allowed = ["www.emanueleferonato.com", "www.triqui.com"];
sitelock(urls_allowed);
function sitelock(urls_allowed) {
    lock = true;
    domain_parts = stage.loaderInfo.url.split("://");
    real_domain = domain_parts[1].split("/");
    domain.text = real_domain[0];
    for (x in urls_allowed) {
        if (urls_allowed[x] == real_domain[0]) {
            lock = false;
        }
    }
    if (lock) {
        stage.alpha = 0;// make sure this function has access to the stage.
    }
}
查看更多
登录 后发表回答