Embed Youtube video in WordPress

I have a code that can play video from youtube, the code works really well, if the URL is like:
/watch?v=tac55PdUmf8&t=4s

But when the Youtube video URL contains a reference to a playlist: then the video will not play.
Example:
/watch?v=yvYQe1IZmXo&list=PLrsfJq-0xXwJC4JDzpKYsiV7_kBeSUh9k

Here is the code, that I am using:

<?php $video = Wpjb_Model_MetaValue::getSingle( "resume_detail", "detail_video", $p->id, true); ?> <?php if( $video && strpos( $video, "youtube" ) !== false ): ?> <?php $video = str_replace("watch?v=", "embed/", $video); ?> <?php elseif ?> <?php endif; ?>

I know that WordPress can play a youtube video just by inserting the URL in a post, but since I am using a plugin I cannot use the WordPress feature.

I am hoping that somebody can help with this issue.

Best Regards

Sponsor our Newsletter | Privacy Policy | Terms of Service