0

So I have background music on a site and I am trying to make the music pause if there is a video on the page, but when I try to echo a script, my embedded video disappears. I am a bit lost on this one:

<?php
$url = 'http://www.youtube.com/watch?v=4PzOqCpxyEU';
preg_match(
    '/[\\?\\&]v=([^\\?\\&]+)/',
    $url,
    $matches
);
$id = $matches[1];

$width = '640';
$height = '385';
echo '<object width="' . $width . '" height="' . $height . '"><param name="movie"      value="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';
if($id = $matches[1]){ 
           echo '<script>jQuery(function(){ app.events.trigger('audioplayer.pause') });    </script>'; } 
 ?>
2
  • You are closing your echo operand after trigger('. Commented Jun 5, 2013 at 10:55
  • try echo '<script>jQuery(function(){ app.events.trigger("audioplayer.pause") });</script>'; } Commented Jun 5, 2013 at 10:56

1 Answer 1

2

escape the '

 echo '<script>jQuery(function(){ app.events.trigger(\'audioplayer.pause\') });</script>';

Also use here == instead of =

if($id == $matches[1])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.