latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Home Forums ryan

About: ryan

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To

Viewing topic 1 (of 1 total)
Topic Count Last Reply
CloudFront and RTMP Streaming JW 1 2

By:  luisrosario in: Community Forum

voices: 5
replies: 35

4 years, 10 months ago  ryan

Viewing topic 1 (of 1 total)

My Latest Replies (From Various Topics)

Viewing 11 replies - 1 through 11 (of 11 total)
Author Replies
Author Replies
Posted: Sunday Mar 4th, 2012 at 6:10 pm #7239
ryan
Username: ryanm

What about running the resulting javascript through a packer/obfuscater? Granted this will not “encrypt” the URIs but will make it less accessible to most views. For those really determined it will increase the time it take them to “find” the URIs, further decreasing the likelihood that one would be able to DL the video before the expiration of the TTL.

Something like Packer JavaScript for PHP (http://joliclic.free.fr/php/javascript-packer/en/).

I did not spend much time looking at s3flowshield, it might do something similar.

Posted: Wednesday Feb 29th, 2012 at 11:54 pm #6860
ryan
Username: ryanm

OK, here is a working function. I feel pretty embarrassed about my first “draft” now.

add_shortcode('fdnVideo_embed', function ($atts){
	$atts = shortcode_atts(
		array(
			'src' 	=>	'',
			'width' =>	'600',
			'height'=>	'338',
			'title' =>	''
	), $atts);
	
	$cfg = array (
		'file_download' => $atts['src'], 
		'url_to_storage_source' => true,
		'count_against_user' => true
	); 

	if (($mp4 = s2member_file_download_url ($cfg, "get-streamer-array"))) { 
		$output = '
				<div id="jw-container">JW Player® appears here.</div>
				<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
				<script type="text/javascript">
        			jwplayer("jw-container").setup({modes: /* JW Player¨. */
        				[
		            		/* First try real-time streaming with Flash¨ player. */
				            {type: "flash", provider: "rtmp", src: "/jwplayer/player.swf",
								config: {streamer: "' . $mp4["streamer"]. '", file: "'. $mp4["file"] .'"}},
        
				            /* Else, try an HTML5 video tag. */
				            {type: "html5", provider: "video",
		        		        config: {file: "'.  $mp4["url"] .'"}},
		        
		            		/* Else, this is a safe fallback. */
				            {type: "download", /* Download the file. */
				                config: {file: "' . $mp4["url"] .'"}}
						],
        		
	        		/* Set video dimensions. */ 
	        		width: '. $atts['width'] .', height: '. $atts['height'] .'
	        		});
	   			</script>';   			
   		} else {   			
   			$output = 'Sorry, you do NOT have access to this file.';   		
   		}	
   		
	return $output;
	});

NOW my issue is that two on one page fails. :) The code appears correct, i.e. two different videos are referenced and two different URIs are generated.

Cheers,
Ryan

Posted: Wednesday Feb 29th, 2012 at 12:39 am #6720
ryan
Username: ryanm

Hi guys,

Thank you for all of the follow ups. I will likely need to implement the isolation that Jason outlined above, but right now I’m focused on making the insertion of videos (with S3/CloudFront) a bit more user-friendly.

Below is my first attempt at a shortcode function that take the perimeters of video file, width, height, and title and builds the code block. Alas, I’m having a bit of an issue with the retuned PHP — the PHP sections are not being processed as PHP. Any thoughts on what I have done wrong and what I could do differently?

add_shortcode('fdnVideo_embed', function ($atts){
	$atts = shortcode_atts(
		array(
			'src' 	=>	'',
			'width' =>	'600',
			'height'=>	'338',
			'title' =>	''
	), $atts);
	

	return '
		<div id="jw-container">JW Player® appears here.</div>
		<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>

		<?php 
			/* A direct URL to the RTMP source; counting the file against the current User in real-time. */
			$cfg = array ("file_download" => "'. $atts['src'] .'", "url_to_storage_source" => true, "count_against_user" => true); 
		?>

		<?php 
			/* API Function `s2member_file_download_url()` returns false if access is denied to the current User. */
			if (($mp4 = s2member_file_download_url ($cfg, "get-streamer-array"))) { 
		?>

		    <script type="text/javascript">
        		jwplayer("jw-container").setup({modes: /* JW Player®. */
        		[
            		/* First try real-time streaming with Flash® player. */
		            {type: "flash", provider: "rtmp", src: "/jwplayer/player.swf",
						config: {streamer: "<?php echo $mp4["streamer"]; ?>", file: "<?php echo $mp4["file"]; ?>"}},
        
		        /* Else, try an HTML5 video tag. */
		            {type: "html5", provider: "video",
        		        config: {file: "<?php echo $mp4["url"]; ?>"}},
        
            		/* Else, this is a safe fallback. */
		            {type: "download", /* Download the file. */
		                config: {file: "<?php echo $mp4["url"]; ?>"}}
				],
        		/* Set video dimensions. */ 
        		width: '. $atts['width'] .', height: '. $atts['height'] .'
        		});
   			</script>

		<?php } else /* Access is denied to the current User. */ { ?>
		Sorry, you do NOT have access to this file.
		<?php }?>
		';
     	 
});

Next I’d like to include perimeters to include HTML5 and DL option with in the shortcode, should one want to make those available on-the-fly.

Cheers,
Ryan

P.S. This code takes advantage of the PHP 5.3’s anonymous functions; so it will only work (as is) on systems running PHP 5.3.

  • This reply was modified 4 years, 10 months ago by  ryan.
Posted: Saturday Feb 25th, 2012 at 2:11 pm #6415
ryan
Username: ryanm

Jason spoke (in his tutorial video) about wrapping the JW code into a plugin. Has anyone whipped one of these up?

Posted: Saturday Feb 25th, 2012 at 1:18 pm #6412
ryan
Username: ryanm

Hi Cristián,

Thank you for the follow up. Could you help refresh my memory and tell me where this section is in the documentation?

Cheers,
Ryan

Posted: Thursday Feb 23rd, 2012 at 11:47 pm #6230
ryan
Username: ryanm

Raam,

I think it was really a operator error.

I thought that I read in some of the s2m documentation that the S3 URI could be set up to have a TTL. Did I misread that? Although the HTML5 URI would still give a member access to download the file it would only be “good” for a fixed amount of time. This would also address another possible issue: once a member has the URI, even for RTMP, they can reference that externally (i.e. on their own site). Or does this would have to be regulated with S3. Is that something that can be done on S3?

Cheers,
Ryan

Posted: Monday Feb 20th, 2012 at 11:34 pm #5814
ryan
Username: ryanm

OK… I think I have resolved the issue.

JWPlayer doesn’t necessarily go in the root of your WP directory, at least not if you just copy the example code. The example code references the root of web directory (i.e. “/jwplayer/jwplayer.js”). So, the issue was PEBKAC all along!

ryan

Posted: Monday Feb 20th, 2012 at 11:28 pm #5812
ryan
Username: ryanm

One step forward… two steps back.

I found that I had the JWPlayer for WordPress plug-in installed (something I was previously playing around with — before S2M). I uninstalled that, deleted the jwplayer dir in the root of my WP dir, recreated the jwplayer dir and and (re)uploaded the files again.

Now I get… nothing. :( Something I noted before pulling the JWP plugin was that if I removed the flash option in the code I was show an HTML5 player.

Ryan

Posted: Monday Feb 20th, 2012 at 11:14 pm #5808
ryan
Username: ryanm

Another “data point;” if I try to viewing the post via the “Preview Changes” button within the edit window nothing is displayed, not even the black “place holder.” However, if I “View” the page the “place holder” is displayed.

I am guessing this points to an issue with the “compiling” the code on the page. To confirm I have “Raw HTML” installed and all four of the check boxes are selected. I also have “Exec-PHP” installed; I have “Execute PHP code in text widgets” selected, and have “Disable the visual editor when writing” selected.

Cheers,
Ryan

Posted: Monday Feb 20th, 2012 at 8:34 pm #5770
ryan
Username: ryanm

Hi luisrosario,

Thank you very much for your response. I see now where the confusion is — I’m sure it all made sense in my head at the time I wrote my post.

I think I followed it exactly, in fact I did just as Jason did and uploaded “video.mp4” to my S3 bucket. Then I copied the code from the JWplayer example and pasted it into a new post.

What I wanted to convey with my example was that the URL

http://site.com/?s2member_file_download=video.mp4

worked and I was able to download the file. I was also able to use the HTML5 URL from the source and download the file using that.

To answer your question to Jason; it does work. This is why Jason suggested that if you wanted something more secure you could remove the HTML5 and download options from the example code. (RTMP doesn’t allow the user to “download” the file just “stream” it.)

I’m sure I “fat-fingered” something and I’m sure it will look beautiful… once I figure out what I have done wrong. :)

Thanks again!

Cheers,
Ryan

Posted: Monday Feb 20th, 2012 at 12:07 am #5673
ryan
Username: ryanm

Hi,

In the dark here… literally.

@Jason that is a great video that you put together and just in time; thanks. However, I’m having a bit of an issue; after following along with you I end up with just a black box where the video should be. I have tested multiple browsers and the all produce the same result — except for Firefox it produces a white/blank area.

I have tested the URL, http://site.com/?s2member_file_download=example-file.zip, and I’m able to download the file. I have checked the source code and I was able to download the file using (the HTML5) URL.

Any thoughts on what I might be doning wrong?

Cheers,
Ryan

Viewing 11 replies - 1 through 11 (of 11 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.