No compatible source was found for this media. error?

Rich Tor Posted in Component Development 4 years ago

Thank You for your time. Great Script. I am not a coder I am new at this . I included a copy of what I did . And it works just fine , Loads video and video does work . Only problem is it shows error on the video (No compatible source was found for this media.) I tried everything. Can you take a look and see if you can see the problem that causes this error? It would be much appreciated. Thank You in advance.
I am embeding video from my personal other site (PHP Melody) video script.

ossncom.php:_

'/(https?:\/\/)(www\.)?(daytonabeachbikeweekevent.com\/embed.php[?]vid=)(.*)/',

ossnembed.lib.php:

This topic has been closed!

[Topic is Close]

Replies
us Rich Tor Replied 4 years ago

Thank You I do Understand? Thanks again. :)

German Michael Zülsdorff Replied 4 years ago

Hi Rich,
it's not your fault - you did a good job, but ...
Trying to embed

https://www.daytonabeachbikeweekevent.com/embed.php?vid=037086743

inside Ossn gives:

www-widgetapi.js:533 Failed to execute 'postMessage' on 'DOMWindow':
The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://www.daytonabeachbikeweekevent.com').

because the recipient is no longer daytonabeachbikeweekevent.com anymore but YOUR site

resulting in:

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media. Tt {code: 4, message: "No compatible source was found for this media."}

All in all a mechanism to prevent sharing across domain boundaries - either intentionally implemented or by mistake.

Anyway, now that we learned that the true video source is in fact youtube.com
let's try to find the youtube id by calling the embed url directly from a browser.

Entering https://www.daytonabeachbikeweekevent.com/embed.php?vid=037086743
and pressing F12 to open the developer console (Network tab) gives

enter image description here

As we see, after executing several javascripts the video is fetched as

https://www.youtube.com/embed/Vm5a6ukaPyY?controls=0&modestbranding=1&rel=0&showinfo=0&loop=0&fs=0&hl=en&enablejsapi=1&origin=https://www.daytonabeachbikeweekevent.com&widgetid=1

And voila: Vm5a6ukaPyY is the youtube id we were searching for

So let's assemble a link Ossn can handle in a posting, and that is:

 https://www.youtube.com/watch?v=Vm5a6ukaPyY

Since it would be a real complicated job to develop the code to accomplish all the steps I did manually, I' d suggest to give up on that embedder, do a search like

https://www.youtube.com/results?search_query=Daytona+Beach

instead and embed the youtube video directly.

us Rich Tor Replied 4 years ago

Sorry heres the rest of what I added:
ossnembed.lib.php:

added:

 else if (strpos($url, 'daytonabeachbikeweekevent.com') != false) {
        return ossn_embed_dbbw_handler($url, $guid, $videowidth);
    }

added:

case 'dbbw':
            $videodiv .= "<iframe src=\"https://www.daytonabeachbikeweekevent.com/embed.php?vid={$url}\" scrolling=\"no\" width=\"$width\" height=\"$height\" allowfullscreen></iframe>";
            break;

added:

/**
 * main www.daytonabeachbikeweekevent.com interface
 *
 * @param string $url
 * @param integer $guid unique identifier of the widget
 * @param integer $videowidth  optional override of admin set width
 * @return string css style, video div, and flash <object>
 */
function ossn_embed_dbbw_handler($url, $guid, $videowidth) {
    // this extracts the core part of the url needed for embeding
    $videourl = ossn_embed_dbbw_parse_url($url);
    if (!isset($videourl)) {
        return false;
    }

    // aspect ratio changes based on video - need to investigate
    ossn_embed_calc_size($videowidth, $videoheight, 640/430, 0);

    $embed_object = ossn_embed_add_css($guid, $videowidth, $videoheight);

    $embed_object .= ossn_embed_add_object('dbbw', $videourl, $guid, $videowidth, $videoheight);

    return $embed_object;
}


/**
 * parse dbbw url
 *
 * @param string $url
 * @return string hash
 */
function ossn_embed_dbbw_parse_url($url) {
    // separate parsing embed url
    if (strpos($url, 'object') != false) {
        return ossn_embed_dbbw_parse_embed($url);
    }                     
    if (preg_match('/(https:\/\/)(www\.)?(daytonabeachbikeweekevent.com\/embed.php[?]vid=)(.*)/', $url, $matches)) {
            // that's the "embed" link suggested by dbbw
            return $matches[4];
    }
}

-