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.

JWPlayer shortcode vs. code provided

Home Forums Community Forum JWPlayer shortcode vs. code provided

This topic contains 22 replies, has 5 voices. Last updated by  Philly 4 years, 5 months ago.

Topic Author Topic
Posted: Saturday Jun 30th, 2012 at 3:42 pm #17979
AMGill
Username: AMGill

I asked this question in Community Forums with no response and since have upgraded to Pro so I am copying this question in the Customer Forums. Feel free to delete the other post with same title.
__________________________________

First of all, I want to thank you for the excellent video tutorials and forum support S2member provides. This is the first membership site I am creating for a client and after a lot of research of features and reviews I went with S2member and I am so happy I did. I cannot believe what you provide for a free plugin – especially the complexity of streaming protected videos. Thank you!

After a lot of review of the AmazonS3/Cloudfront/JW Player information, I was able to successfully stream videos on the site. However I am still confused on what the difference is from using the code you provide to stream the video and inserting the JW Player with an External URL. Both work but I am looking for an easy way to hand this site over to my client and to paste and fiddle with the code every time may scare them. I would much rather use the JW Player shortcode if there is no difference. If the page the video(s) is on is already restricted does it matter?

Plus what is the best way, if the code is indeed better, to add multiple videos on a page or post? Is it just a matter of copying and pasting the code several times?

Thanks in advance for your help

List Of Topic Replies

Viewing 22 replies - 1 through 22 (of 22 total)
Author Replies
Author Replies
Posted: Saturday Jun 30th, 2012 at 3:57 pm #17980

Hi Ann,

Are you using AmazonS3/Cloudfront then?

However I am still confused on what the difference is from using the code you provide to stream the video and inserting the JW Player with an External URL.

Do you mean using longtail’s hosted copy of the video player?

If so would not recommend using it as you have no control over it, much better to use your own copy.

Can you post the code your using that works?

Thanks

Posted: Saturday Jun 30th, 2012 at 4:32 pm #17982
AMGill
Username: AMGill

Thanks for the quick response.

I am wondering the benefits of using the example code provided by S2member Download Options (JW Player® ( RTMP streaming MP4, via s2Member’s Amazon® S3/CloudFront integration) VERSUS the JW shortcode that comes with the JWPlayer WordPress plugn. Both work, but JW Player has more control of the player & is much easier for my client to add themselves of course. Both of the codes I use are below.

<?php
// Configuration.
$s2_jw_config["jwplayer"] = "/wp-content/uploads/jw-player-plugin-for-wordpress/player/"; // Relative URL path to JW Player files directory.
$s2_jw_config["mp4_video_file_name"] = "video.mp4"; // Name of your MP4 test file.
// Don't edit anything else below unless you know what you're doing.
?>

<div id="jw-container">JW Player® appears here.</div>
<script type="text/javascript" src="<?php echo $s2_jw_config["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" => $s2_jw_config["mp4_video_file_name"], "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: "<?php echo $s2_jw_config["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: 480, height: 270
        });
    </script>

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

[jwplayer mediaid="1546"]

JW shortode:

[jwplayer mediaid="1542"]
Posted: Saturday Jun 30th, 2012 at 5:50 pm #17988

Ann,

Where are your videos located?
wp-content/uploads, wp-content/plugins/s2member-files/ or in an amazon s3 bucket?

Posted: Saturday Jun 30th, 2012 at 6:20 pm #17989
AMGill
Username: AMGill

The videos are located in an Amazon bucket, but I set the video URL for the JWPlayer shortcode as wp-content/plugins/s2member-files/video.mp4 and it worked…pointing to my Amazon bucket (nothing is in the s2member-files folder). The video is not set as public. So are there any disadvantages to using the JWPlayer shordcode? The video seems only viewable to logged in users and it is MUCH easier my client to set up when they load new videos into their bucket.

Just making sure I am not missing anything.

Posted: Saturday Jun 30th, 2012 at 7:09 pm #17992

Thats brilliant it all works fine for me too under certain conditions and the signature is being created.

So I can’t see a problem with using that plugin and your right its so much easier.

I couldn’t get it to work using /?s2member_file_download=/, it throw a cross domain warning at me and I couldn’t get it to work using my CNAME’s.

It just makes me wonder why s2member doesn’t have a shortcode then unless there is a limitation I havent thought of.

Anyway I’m sure a support rep will enlighten us if there is.

Posted: Saturday Jun 30th, 2012 at 7:35 pm #17993

Are you using cloudfront in the shortcode config? Or is it only accessing video via S3?

Posted: Saturday Jun 30th, 2012 at 7:59 pm #17995
AMGill
Username: AMGill

Luisrosario, NO not cloudfront in the shortcode config, but the URL points straight to the s2member file directory: (ex. http://www.mysite.com/wp-content/plugins/s2member-files/video.mp4) even though Amazon & Cloudfront is where the videos are stored. Since it is set up that way through the s2member settings, anything pointing to the s2member-files directory points to the Amazon bucket….I believe that is how it works.

Philly, yes it would be very nice if s2member had a shortcode.

Posted: Saturday Jun 30th, 2012 at 8:58 pm #17998

Hey Ann Maire Gill, actually I’m very familiar with video streaming using the jwplayer, but have been using it via the javascript calls similar to the code examples. I tried using the plugin and couldn’t get it to work. But now, I realized using your method, it’s probably safe to say that one might use the mod rewrite urls that s2 provides to possibly get some of the same functionality that code examples can do. You could build cloudfront usage into the url that you are using to have the video served via cloud front and not just s3. You’ll find that cloudfront will give you seekable video plus delivers faster. To answer your initial question, I don’t foresee any problem using the plugin since it’s using the same javascript that code samples use, and since you are calling the video file via s2member-files, that triggers your s2 protection on s3 provided that you have successfully configured s2 with s3 lol… The plugin is great because you load other plugins like analytics ect.. It would be cool for s2member could add some support with plugin so they don’t have to reinvent the wheel on providing shortcodes.

Posted: Saturday Jun 30th, 2012 at 9:06 pm #17999

I have s3 setup with cloudfront and thought I would just mess around creating a shortcode to use without a plugin.

This put in functions.php or used to make a mini plugin works for me

// video shortcode
function video_function($atts) {
   extract(shortcode_atts(array(
      'file' => '',
	  'width' => '630',
	  'height' => '335',
	   'image' => ''
   ), $atts));

   
   $return = '<div id="videoplayer"></div>
   
<script type="text/javascript" src="' . get_bloginfo( 'siteurl' ) . '/jwplayer/jwplayer.js"></script>

<script type="text/javascript">
        {
            jwplayer("videoplayer").setup({
				image: "/wp-content/uploads/' . $image . '",
				file: "/wp-content/plugins/s2member-files/' . $file . '",
				modes:
            [
                {type:"flash","src":"' . get_bloginfo( 'siteurl' ) . '/jwplayer/player.swf"},
            
                {type: "html5", provider: "video",
                    config: {file: "/wp-content/plugins/s2member-files/' . $file . '" }},
            
                {type: "download",
                    config: {file: "/wp-content/plugins/s2member-files/' . $file . '" }}
            ],
				width: '.$width.', height: '.$height.',
                });
        }
        
</script>';

   return $return;
}

add_shortcode('video', 'video_function') ;

Usage

[video file="videos/myvideo.mp4"]

optional parameters: width and height default to 630px and 335px respectively if not specified, and image

This is just a basic implementation and assumes jwplayer files are located http://yoursite.com/jwplayer/here

and that your just using mp4 as the file type.

This is a stripped down version I have it working with the jwplayer plugins too.

Posted: Saturday Jun 30th, 2012 at 9:13 pm #18000

This is cool. How would you implement this if I wanted to generate a key for each time a person accesses a video?

Posted: Saturday Jun 30th, 2012 at 9:17 pm #18001

@ luisrosario

A key so you can use this with cloudfront?

Posted: Sunday Jul 1st, 2012 at 2:24 pm #18038

Hey Philly, so yes, using cloudfront. This extends the ability to issue keys on a per video basis bypassing download restrictions extending more control to you when the keys are being issued.

Posted: Sunday Jul 1st, 2012 at 2:35 pm #18039

@ luisrosario

I’m able to get it to output with the key using

s2member_file_download_key( $file )

but the player throws not found or cross domain errors at me, even though the link with the generated key works if directly put in the browser.

Also I’m not sure how to get the shortcode working with rmpt yet. And to be honest I’m not sure exactly how it all works yet.

Posted: Sunday Jul 1st, 2012 at 2:48 pm #18040

Lol.. Ok.. well what do you need help with? I might be able to lend some assistance.. I’m pretty familiar with how it all works, but I’m not a coder per say.. I have developers who do that for me lol..

Posted: Sunday Jul 1st, 2012 at 2:55 pm #18041

What code are you currently using that works with the key?
Would be interested to see that

Posted: Sunday Jul 1st, 2012 at 3:04 pm #18042

Hey Philly.. Check out this thread. This a thread between Jason and I regarding several different ways to trigger s3 and cloud front with JW player. It goes into detail with some variations on how to use jwplayer with s2member.. I believe the code in question is towards latter half of the thread.. Lots of useful info on this thread. I would copy and past some of these examples for your reference.

http://www.s2member.com/forums/topic/cloudfront-and-rtmp-streaming-jw/

Posted: Wednesday Jul 4th, 2012 at 10:13 am #18297

Here is a working shortcode for the folllowing setup:

MP4, s3, cloudfront, CNAME’s with a download key.

First tries streaming via rtmp then falls back to http with html5 fallback.

This is stripped down, can be adapted to use multiple fallbacks and JWPlayer plugin integration(I have it working with HD plugin)

Happy to bundle this into a mini plugin with customization, if requested.

function s2video_function($atts, $content) {
	extract( shortcode_atts( array(
				'file' => '',
				'image' => '',
				'width' => '630',
				'height' => '335'
				), $atts ) );


$mp4 = do_shortcode('[s2File download="'.$file.'" url_to_storage_source="true" count_against_user="true" get_streamer_json="true" /]');

	$return = '
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
<video id="videoplayer"></video>
<script type="text/javascript">
	var mp4 = '.$mp4.' ;
</script>
				
<script type="text/javascript">
    if(typeof mp4 === \'object\') 
        {
            jwplayer("videoplayer").setup({
				image: \'/wp-content/uploads/'. $image . '\' ,
				modes:
            [
                {type: "flash", provider: "rtmp", src: "/jwplayer/player.swf",
                    config: {streamer: mp4[\'streamer\'], file: mp4[\'file\']}},
            
                {type: "html5", provider: "video",
                    config: {file: mp4[\'url\']}},
            
                {type: "download",
                    config: {file: mp4[\'url\']}}
            ],
				width: '.$width.', height: '.$height.',
              });
        }
    else
        {
            document.write(\'Sorry, you do NOT have access to this file.\');
        }
</script>
				
					';
					return $return;
}
add_shortcode('s2video', 's2video_function') ;

Usage:

[s2video file="relative to root of S3 Bucket" image="relative to wp-content/uploads/" width="defaults to 630" height="defaults to 335"]
Posted: Thursday Jul 5th, 2012 at 12:34 am #18340

Very nice, Philly!

Posted: Friday Jul 13th, 2012 at 2:07 am #19128
seamsite
Username: nomadznet

@luisrosario

I, too, have been using the JW Player plugin. I think it’s a much more elegant solution to the php code. However, I cannot get the RTMP streaming to work.

For example this works (but is not RTMP):

[jwplayer file=”http://www.seam.tv/wp-content/plugins/s2member-files/s2member-file-storage-cf/video.mp4&#8243;

This does not:

[jwplayer config=”s2video” file=”http://www.seam.tv/wp-content/plugins/s2member-files/s2member-file-storage-cf/video.mp4&#8243;

(s2video is a preset using my streaming setup in Cloudfront: rtmp://s2xxxxxxxxxxxx.cloudfront.net:1935/cfx/st)

This doesn’t work either:

[jwplayer file=”http://www.seam.tv/wp-content/plugins/s2member-files/s2member-file-storage-cf/video.mp4&#8243; streamer=”rtmp://s2xxxxxxxxxxxx.cloudfront.net:1935/cfx/st” provider=”rtmp”]

I wonder if anyone else has managed to get this to work?

Posted: Friday Jul 13th, 2012 at 5:34 am #19139

Although it appears to work with the wordpress plugin I think the limitation comes with the rtmp bit and I don’t think s2member is able to create the signed url for it to work.

Therefore I would say in the case RTMP streaming the wordpress plugin is not compatible.

If you need a shortcode with RTMP use the one above.

@ seamsite

please use the shortcode provided above, just add the function part to your functions.php file.

Also you should read this topic as it affects you http://www.s2member.com/forums/topic/s2member-and-cloudflare/

Hope that helps.

Posted: Friday Jul 13th, 2012 at 6:53 am #19151
seamsite
Username: nomadznet

@Philly Thank you so much for the heads-up on Cloudflare. That really comes in handy.

I have managed to get the php coding to work with RTMP but hope to find a short code alternative in future, as it’s much easier to deal with – and give to other people to work on – than embedding php in every page that requires the player.

Thanks for all your help!

Posted: Friday Jul 13th, 2012 at 8:57 am #19166

@ seamsite

If you show me what code your using I can turn it in to a mini plugin so you can use a shortcode instead of embedding the php

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

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

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.