Domanda

Implementing EasyCaptions on my WordPress blog and I’ve hit a brick wall. Any help would be appreciated. I’m using SWFobject to embed videos. I’ve pasted this code: http://pastebin.com/0ZMSr0Bz into my header.php and this embed code in my posts:

<video id="video-html5" width="480" height="320" controls="controls"
        source src="[url to video]" />
</video>

The problem is the implementation only works for the video defined here:

var flashvars = { file:'[video url]', ...

All other videos embeds do not work. I've tried using a playlist but that did not solve the problem. How do I solve this? Do I need additional JS or PHP code to add to the file parameter?

È stato utile?

Soluzione 2

The solution lies in NOT hard-cording the video url in the header.php. Here is what worked to solve this. I first created a custom field in wordpress, named it thinema, and then set the value of the custom field to be the embedded video url in the post. Then edited this code into my header.php

flashvars = { file: '<?php echo get_post_meta(get_the_ID(), thinema, true); ?>'...

I've updated the code in pastebin. Hope this is of use to someone! You can view the implementation here.

Altri suggerimenti

[edited post]

I just re-read your question and looked at the pastebin. The video URL you're using is an HTML file: http://vidbull.com/embed-iqkhawkkx1rn-640x318.html. You can't load an HTML file as a video.

Try it again using a proper video URL (MP4, F4V, OGG, etc).

-- UPDATED based on comment from OP --

The issue is that you're hard-coding the video URL in your WordPress header. What you'll need to do is use a variable instead. I suggest using WordPress' "shortcode" API, which will enable you to pass variables via a custom shortcode.

Define your shortcode in WordPress, something like:

//[easycaptions]
function embed_easycaptions( $atts ){
  //your custom PHP code here, using the passed $atts
}

add_shortcode( 'easycaptions', 'embed_easycaptions' );

Then when authoring your WordPress blog post, you add the custom shortcode where desired, such as

[easycaptions url='http://localhost/wordpress1/wp-content/uploads/2012/10/Sheldon-in-a-Dress.mp4']

Check out the Shortcode API page for instructions and examples. It's a pretty powerful system.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top