You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Flowplayer playback from private Amazon S3 storage Created Mar 23, 2009

This thread is solved

Views: 8668     Replies: 37     Last reply Sep 8, 2011  
You must login first before you can use this feature

chad_rfg

Posts: 5

Registered:
Jul 10, 2008

Flowplayer playback from private Amazon S3 storage

Posted: Mar 23, 2009

I have recently started hosting my videos on Amazon S3. This works great for all my publicly available videos. So for example, this type of link works fine:

http://s3.amazonaws.com/SudokuProfessor/FreeLesson1.flv

However, I have a set of videos that are only available to paid subscribers, so I'm storing them on Amazon S3 as private, then attempting to access them with what's known as "Query String Request Authentication." Simply stated this is a string would be similar to the one above, but it has authentication after it like this (this is not an actual working link):

http://s3.amazonaws.com/SudokuProfessor/FreeLesson1.flv?AWSAccessKeyId=0BKB3R8R2JJP3NSVJ1ND&Expires=1237709891&Signature=4ksLAFiKXna1EJ/AQeY=p/Y6NCVS

When I use a link like that, Flowplayer does nothing. The playback area goes black and nothing happens (not even an error message).

My guess is that all the stuff after the actual flash video file name (from the question mark on) is confusing it. I assume that it doesn't know what type of video it is (or maybe that it's a video at all).

(For those of you who understand S3 access, I have confirmed that my signature is correct, and I can use the link in the address bar of my browser to download the file. It's just that Flowplayer won't play anything.)

Does anyone know of a work-around in Flowplayer for this. I know I can probably work around it in S3, but that would mean making these videos publically accessible.

Thank you!!

inappropriatedan

Posts: 2

Registered:
Apr 4, 2009

» Flowplayer playback from private Amazon S3 storage

Posted: Apr 4, 2009

Reply to: Flowplayer playback from private Amazon S3 storage, from chad_rfg
Hi,

I'm interested in doing this too. Is it simply a case of escaping the ampersand as discussed on this thread?

http://flowplayer.org/forum/8/15861

inappropriatedan

Posts: 2

Registered:
Apr 4, 2009

» » Flowplayer playback from private Amazon S3 storage

Posted: Apr 5, 2009

Reply to: » Flowplayer playback from private Amazon S3 storage, from inappropriatedan
scrub that - I seem to be able to get it to work just by passing in the URL from javascript i.e.


flowplayer("player", "../flowplayer-3.0.7.swf");
$f().play('https://s3.amazonaws.com/xxx/xxx.flv?AWSAccessKeyId=xxx&Expires=xxx&Signature=xxx');

soundlab

Posts: 1

Registered:
Sep 3, 2009

More Help On this please??

Posted: Sep 3, 2009

Reply to: » » Flowplayer playback from private Amazon S3 storage, from inappropriatedan
Just curious if you could explain in a bit more detail.. I'm new to the S3 and Flowplayer, but would like to get this workin.. I currently have the player embedded as an Object and trying to you use the Authenticated Url, but it doesn't

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

same issue: I can authenticate, but it won"t play

Posted: Sep 28, 2009

Reply to: Flowplayer playback from private Amazon S3 storage, from chad_rfg
I can manually copy and paste the link, and S3 will allow me to download the FLV, so I know I'm authenticating. But the player does nothing; just a black box.

I've tried this method


<script type="text/javascript">
flowplayer("player", "flowplayer-3.1.3.swf");
$f().play('<?php echo htmlentities($link); ?>');
</script>

This would be beautiful--if I could make it work.

kuroi

Posts: 1

Registered:
Oct 1, 2009

Use urlencode

Posted: Oct 1, 2009

Reply to: same issue: I can authenticate, but it won"t play, from spinhead
@spinhead

Try using urlencode instead of htmlentities. Worked for me, and I didn't even need to load the file via javascript (I was able to load it as an href attribute on the anchor tag).

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

sweet merciful heavens

Posted: Oct 1, 2009

Reply to: Use urlencode, from kuroi
Thank you SO much, kuroi.

Great googlymooglies that's not obvious. Works like a charm.

I'm going to go write up a tutorial of the entire process and save some other poor chap all the grief.

from_disaster

Posts: 2

Registered:
Oct 19, 2009

» sweet merciful heavens

Posted: Oct 19, 2009

Reply to: sweet merciful heavens, from spinhead
@spinhead I was wondering if you had a chance to write this all up. Really interested in getting this working myself and I'd rather not re-invent the wheel if I don't have to!

Thanks!

jb123

Posts: 31

Registered:
Oct 16, 2009

» » sweet merciful heavens

Posted: Oct 19, 2009

Reply to: » sweet merciful heavens, from from_disaster
Hi all,

Though not entirely on point to your situation I also bumped into a pesky querystring issue that's now solved. I'm sure you can appreciate my "fun" figuring out how to make it work ;)

http://flowplayer.org/forum/3/29492

Regards,
-JB

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

here"s the code and walkthrough

Posted: Oct 19, 2009

Reply to: » sweet merciful heavens, from from_disaster
I did indeed write it up; there's a temporary home here

http://72.9.251.146/~bizbacom/code/secure_s3.php

and that page will bounce to the real home once everything's nailed down.

Very interested in any feedback on what I wrote up?especially if it actually solves your problem.

from_disaster

Posts: 2

Registered:
Oct 19, 2009

» here"s the code and walkthrough

Posted: Oct 19, 2009

Reply to: here"s the code and walkthrough, from spinhead
Thank you, very much! I hope to use this for an audio player. I assume it will work out the same way. Planning on tackling this later in the week and will definitely reply back with my results. Thanks, again!

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

S3 and secure audio

Posted: Oct 19, 2009

Reply to: » here"s the code and walkthrough, from from_disaster
Hey, let me know how that works out. I haven't done it with audio, but the basics should be there.

jb123

Posts: 31

Registered:
Oct 16, 2009

» here"s the code and walkthrough

Posted: Oct 19, 2009

Reply to: here"s the code and walkthrough, from spinhead
Hi Joel,

I just read your Tutorial. It is easily the best software related tutorial I have read over the past 15 or so years! Excellent writing style and very informative. I am getting my first video site setup now and was considering using a CDN for all the reasons you mention. Afer reading your tutorial I have decided to follow your lead and go with Amazon S3. I'll work on that next week and let you know my experience following your instructions.

On a very trivial point, you may want to change "use PHP 5" to use "at least" PHP 5.0

Again, great job!
Thank,
-JB

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

writing how-to stuff

Posted: Oct 19, 2009

Reply to: » here"s the code and walkthrough, from jb123
thanks very much, JB; as a business author and coach I obsess about good teaching. (perhaps that's why my "How to write a how-to" article from evolt.org made its way into the Apache documentation archives ;)

jb123

Posts: 31

Registered:
Oct 16, 2009

» writing how-to stuff

Posted: Oct 19, 2009

Reply to: writing how-to stuff, from spinhead
Congrats on finding your way into the Apache documentation.

narko

Posts: 5

Registered:
Oct 30, 2009

» here"s the code and walkthrough

Posted: Nov 10, 2009

Reply to: here"s the code and walkthrough, from spinhead
unfortunately walkthrough is not accessible anymore, can you please repost it somewhere?

thanks a lot in advance!

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

updated link to the code walkthrough

Posted: Nov 10, 2009

Reply to: here"s the code and walkthrough, from spinhead
d'oh; apologies. here's an updated link

http://72.9.251.146/~spinhead/code/secure_s3.php

checkmark

Posts: 1

Registered:
Nov 12, 2009

WOW!! Thank You!!

Posted: Nov 12, 2009

Reply to: updated link to the code walkthrough, from spinhead
I registered for this forum just so I could post a BIG THANKS for this excellent tutorial. I can't believe it worked first try! Thank you so much for putting in the effort to make this tutorial thorough and clear enough that anyone (maybe even someone who doesn't know any PHP) can follow.

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

you are entirely welcome!

Posted: Nov 12, 2009

Reply to: WOW!! Thank You!!, from checkmark
I get a huge kick out of this. Thanks! Maybe I'll finally formalise it into an article at http://evolt.org/

Abbey

Posts: 20

Registered:
Sep 11, 2009

nice tutorial!

Posted: Nov 30, 2009

Reply to: you are entirely welcome!, from spinhead
I like it! You should do a demo page too!

Also, what about having multiple videos on a page?

Would I make the $resource equal an array of videos perhaps?

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

multiple videos

Posted: Nov 30, 2009

Reply to: nice tutorial!, from Abbey
Thank you :)

You'd have to assign multiple IDs, or loop, and reassign a new value each time through.

Someday when my business books make me rich, I'll take the time to code up a multi-video page.

AndrewTraub

Posts: 4

Registered:
Dec 12, 2009

Doesn"t work after urlencode

Posted: Dec 12, 2009

Reply to: updated link to the code walkthrough, from spinhead
If I echo the link generated without the urlencode and copy that into the browser bar, the link works, but does not work with flowplayer.

If I urlencode($link) and echo that value, it does not work for the flowplayer and does not work when copied into the browser bar.

Any ideas?

Andrew

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

urlencode problem

Posted: Dec 12, 2009

Reply to: Doesn"t work after urlencode, from AndrewTraub
Andrew, are you talking about line 34? If so, dunno what's wrong. Could you post your code somewhere for review?

AndrewTraub

Posts: 4

Registered:
Dec 12, 2009

test.php

Posted: Dec 22, 2009

Reply to: urlencode problem, from spinhead

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml4/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Video</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<script type="text/javascript" src="/js/flowplayer-3.1.4.min.js"></script>
</head>
<body>
<?php
    define("AWS_S3_KEY", "hidden");
    define("AWS_S3_SECRET", "hidden");
    $expires = time()+60*60;
    $bucket = "mybucket";
    $resource = "folder/file.mp4";
    $string_to_sign = "GET

{$expires}
/{$bucket}/{$resource}";
    $signature = urlencode(base64_encode(hash_hmac("sha1", utf8_encode($string_to_sign), AWS_S3_SECRET, TRUE)));

    $authentication_params = "AWSAccessKeyId=".AWS_S3_KEY;
    $authentication_params.= "&Expires={$expires}";
    $authentication_params.= "&Signature={$signature}";
    $link = "https://{$bucket}.s3.amazonaws.com/{$resource}?{$authentication_params}";
?>
<?php
	echo $link;
	echo "<br /><br />";
	echo urlencode($link);
	echo "<br /><br />";
	echo htmlentities($link);

        echo "<a href="".urlencode($link)."" id="player"></a>";
?>
<script type="text/javascript">
	flowplayer("player", "flowplayer-3.1.5.swf",
	{
		clip:
		{
			autoPlay: false,
			autoBuffering: true
		}
	});
</script>
</body>
</html>

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

escaping double quotes

Posted: Dec 22, 2009

Reply to: test.php, from AndrewTraub
I'm still fuzzy on quoting in PHP, but shouldn't the outer double quotes be escaped?

http://evolt.org/s3secure#code_line_34

I tried pasting the code here, but no matter how I did it, the dialog box actually ran the code, which echoed an empty string. That don't make no sense . . .

AndrewTraub

Posts: 4

Registered:
Dec 12, 2009

Escaping double quotes

Posted: Jan 1, 2010

Reply to: escaping double quotes, from spinhead
The form converted them when I posted the code (not sure why), but they were properly escaped, but I went ahead and replaced the backslash-quote combination with just the apostrophe - same results.

The test.php page can be found athttp://www.cpaaffiliatetraining.com/test.php (of course, that will only give you the final output)

Andrew

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

Andrew"s video works?

Posted: Jan 1, 2010

Reply to: Escaping double quotes, from AndrewTraub
When I follow that link, the video plays fine.

Are you not seeing that result?

AndrewTraub

Posts: 4

Registered:
Dec 12, 2009

Video

Posted: Jan 2, 2010

Reply to: Andrew"s video works?, from spinhead
Using firefox, I see threehttps://... lines on the page, but no video.

I tried it in IE and the video did appear (though it looked distorted) - any idea why firefox doesn't work?

Thanks,

Andrew

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

your video not working

Posted: Jan 3, 2010

Reply to: Video, from AndrewTraub
I can't get it to work anywhere now.

Pretty sure you're facing a PHP issue beyond my knowledge. If you know a PHP person or support group, they're gonna be more helpful than I can; sorry.

If you don't know a group, you can join the email list athttp://lists.evolt.org/ and there are a few thousand helpful people who'd probably come up with a solution right quick.

spinhead
Business Heretic

Posts: 16

Registered:
Sep 28, 2009

permanent link to the code and article

Posted: Dec 12, 2009

Reply to: updated link to the code walkthrough, from spinhead
I wrote this up as an article for evolt.org where it will live on forever:http://evolt.org/s3secure

Yingchun5207

Posts: 1

Registered:
Sep 8, 2011

» permanent link to the code and article

Posted: Sep 8, 2011

Reply to: permanent link to the code and article, from spinhead
Thank you for sharing . The post growth of my knowledge.
Cheap Coach Purses