JW Player and WPUFP

This topic contains 8 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 6 months ago
Viewing 8 Posts - 1 through 8 (of 8 total)
Author Posts
October 15, 2013 at 2:09 am 9017
Tareq Hasan Hi There, I have a project which uses custom posts to present media files which are uploaded through the wordpress media uploader. I purchased the plugin after playing with the free version and it's excellent, the one problem is that the pro version doesnt use the standard WP media uploader. Basically I need it to upload to the site and output the file url like: [video width="1280" height="720" mp4="http://sitename/wp-content/uploads/2013/10/filename.mp4"][/video] Would you be able to recommend the best way around this? Thanks in advance, Ben
October 15, 2013 at 10:13 pm 9034
Tareq Hasan Tareq Hasan

May be you should edit your themes single.php to show the video like this:
[php]
$video_id = get_post_meta( $post->ID, ‘your_video_meta’, true );
$url = wp_get_attachment_url( $video_id );
echo do_shortcode( ‘[video width="1280" height="720" mp4="' . $url . '"][/video]‘ );
[/php]

October 16, 2013 at 4:59 pm 9069
Ben Ben

Hi There,

Thanks for the reply. I tried this but I dont think it’s working. Here’s the code I’m using to call the video in the template, would you be able to suggest how I change it?

It was working perfectly with the free plugin.

Thanks
B

have_posts() ) : $resource_video->the_post(); // Check for our video ?>

Video player loads here.

October 16, 2013 at 5:06 pm 9070
Ben Ben

Sorry, code truncated, full version here:

				<?php while ( $resource_video->have_posts() ) : $resource_video->the_post(); // Check for our video ?>
					<div id="player">
						<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/jw/jwplayer.js"></script>
						<div id="mediaspace">Video player loads here.</div>
						<script type="text/javascript">
						    jwplayer("mediaspace").setup({
						        flashplayer: '<?php bloginfo( 'stylesheet_directory' ); ?>/jw/player.swf',
						        file: '<?php echo $post->guid; ?>',
						        width: 640,
						        height: 360
						    });
						</script>
					</div>
				<?php endwhile; ?>
October 17, 2013 at 10:23 pm 9149
Tareq Hasan Tareq Hasan

Put this code in the WordPress loop.
[php]
$video_id = get_post_meta( $post->ID, ‘your_video_meta’, true );
$url = wp_get_attachment_url( $video_id );
[/php]

Now print the url in the jw player JavaScript code.
[js]file: ‘<?php echo $url; ?>’,[/js]

October 18, 2013 at 8:47 pm 9182
Ben Ben

I’m really sorry but I cant get this one to work with the meta, would you be able to give a more complete example based on the code I provided?

Thanks again, your help is much appreciated.

Ben

October 18, 2013 at 9:15 pm 9185
Tareq Hasan Tareq Hasan

Here’s the complete code:

[php]
<?php while ( $resource_video->have_posts() ) : $resource_video->the_post(); // Check for our video ?>
<div id="player">
<script type="text/javascript" src="<?php bloginfo(‘stylesheet_directory’); ?>/jw/jwplayer.js"></script>
<div id="mediaspace">Video player loads here.</div>
<script type="text/javascript">
<?php
$video_id = get_post_meta( $post->ID, ‘your_video_meta’, true );
$url = wp_get_attachment_url( $video_id );
?>
jwplayer("mediaspace").setup({
flashplayer: ‘<?php bloginfo( ‘stylesheet_directory’ ); ?>/jw/player.swf’,
file: ‘<?php echo $url; ?>’,
width: 640,
height: 360
});
</script>
</div>
<?php endwhile; ?>
[/php]

October 18, 2013 at 9:31 pm 9187
Ben Ben

Thanks Tareq,

It’s not done the trick, I think there might be some conflicting stuff in the loop section above. It’s using the custom post type ‘resource’.

Any idea what the problem might be?


<?php get_header(); ?>

<?php // Let's get the data we need
	$recording_date = get_post_meta( $post->ID, 'recording_date', true );
	$recording_length = get_post_meta( $post->ID, 'recording_length', true );
	$resource_presenters = get_the_term_list( $post->ID, 'presenters', '', ', ', '' );
	$resource_topics = get_the_term_list( $post->ID, 'topics', '', ', ', '' );
	$url = wp_get_attachment_url( $video_id );
	$resource_video = new WP_Query( // Start a new query for our videos
	array(
		'post_parent' => $post->ID, // Get data from the current post
		'post_type' => 'attachment', // Only bring back attachments
		'post_mime_type' => 'video', // Only bring back attachments that are videos
		'posts_per_page' => '1', // Show us the first result
		'post_status' => 'inherit', // Attachments require "inherit" or "all"
		)
	);
	$video_id = get_post_meta( $post->ID, 'your_video_meta', true );
	$url = wp_get_attachment_url( $video_id );

?>

I really appreciate the support, when we get this sorted please could you point me to your preferred link for me to rate and review.

Kind regards,

Ben

October 18, 2013 at 9:50 pm 9189
Tareq Hasan Tareq Hasan

Are you providing the right meta key? I am using a sample key named your_video_meta. Make sure you are replacing this with your own meta key that is being used in the post.

You can paste the whole code in pastebin.com for better idea what you are trying to do.

Viewing 8 Posts - 1 through 8 (of 8 total)