简体   繁体   中英

Amazon S3 signed url not working with flowplayer

I've searched everywhere but cannot find an answer. I am using flowplayer and amazon s3 with PHP. The link works in the browser if I copy and paste but it appears flowplayer doesn't like query strings. I tried replacing the html entities then url encoding it. I just tried url encoding it. I just tried removing the & and replace with & etc. None of these worked.

My goal is to play a url signed video from amazon s3 using flow player.

I know I have no code to display because none of it is 'right' but does anybody have any suggestions? They would be much appreciated.

I had this same problem, and discovered the answer by reading the ActionScript source code for the Flowplayer cloudfrontsignedurl plugin:

http://flash.flowplayer.org/documentation/developer/development-environment.html

private function _getUrl(clip:Clip):String {

    var url:String = clip.getPreviousResolvedUrl(this);

    var isRTMPStream:Boolean = url.toLowerCase().indexOf('mp4:') == 0;
    if ( isRTMPStream )
        //gets the url, minus the "mp4:" at the beginning
        url = url.substr(4);

    //gets the expires time in seconds
    var expires:Number = Math.round((new Date()).getTime() / 1000 + _config.timeToLive);

    //generate the signed url
    var signedUrl:String = _signedUrlGenerator.signUrl(url, expires);

        //put the 'mp4:' back on the front
    if ( isRTMPStream )
        signedUrl = 'mp4:'+ signedUrl;

    return signedUrl;

}

Notice how it removes the "mp4:" prefix before signing the url, then adds it back on afterward.

I followed Amazon's example, here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CreateURL_PHP.html

Then the relevant parts of my JavaScript config look like this:

var netConnectionUrl = "rtmpte://amazon_distribution_domain_name.cloudfront.net/cfx/st";
var clipUrl          = "folder/folder/videofile.mp4";

$.post('/path/getSignedUrl.php', {clipUrl:clipUrl}, function(signedUrl){
  clipUrl = 'mp4:'+signedUrl;

  ...then add netConnectionUrl and clipUrl to Flowplayer config...
});

I preferred to use PHP instead of the Flowplayer plugin so that I could also check to make sure the user is logged in and owns the product, etc., before signing the URL, and was able to do my domain and IP address checks with PHP also without needing to fuss around with compiling with Ant or Flash Builder. And this way the private key stays off of the client. Using the plugin would mean that pirates could possibly steal the SWF file, but by using AJAX and signing the url on the server, means it's impossible to steal.

Use this extension to make a signed URL and make sure that it works

Make sure the path is correct, that is local or global path....

Try to play an unsigned URL, then after that works flip to a signed URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM