View Single Post
Old 06-19-2011, 04:30 PM   #4
Lenwë Sáralondë
Initiate
 
Join Date: Jun 2011
Posts: 2
Lenwë Sáralondë is unknown at this point
Okay, I finally managed to do it.

Easy way: To insert just one specific video to any web page, just copy/paste the code from the WCM page. Add FlashVars "autostart=false" to prevent the video to play automatically.

Example with this video http://www.warcraftmovies.com/movieview.php?id=190731 :
HTML Code:
<object width="685" height="386">
	<param name="movie" value="http://embed.minoto-video.com/42/yo6x6NZPdMxr" />
	<param name="allowFullScreen" value="true" />
	<param name="allowscriptaccess" value="always" />
	<param value="autostart=false" name="FlashVars" />
	<embed FlashVars="autostart=false" src="http://embed.minoto-video.com/42/yo6x6NZPdMxr" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="685" height="386" />
</object>
Just use "show source" to get the mvie URL.

Hard way: Embedded player from the WCM URL using PHP. This what I used for my future PHPBB3 forum, to implement a generic [video] tag supporting various video hosts.

First of all, you must get the Minito video ID from the web page HTML.

PHP Code:
/**
 * Return the specs of the video from its URL
 * 
 * @param string $url
 * @param string $type
 * @param string $id
 * @param int    $width
 * @param int    $height 
 * @return boolean true if the video type has been recognized
 */
function detect_video_specs($url, &$type, &$id, &$width, &$height)
{    
    
$parsedUrl parse_url($url);
    
    
$queryParams = array();
    
    if (!empty(
$parsedUrl['query']))
        
parse_str($parsedUrl['query'], $queryParams);
    
    
$type   null;
    
$id     null;
    
$width  null;
    
$height null;    
    
    
// Warcraft movies
    
if (preg_match('/^(www\.)?warcraftmovies\.com$/i'$parsedUrl['host']) &&
             
preg_match('/^\/movieview\.php$/i'$parsedUrl['path']) && 
                    !empty(
$queryParams['id']))
    {
        
// Grab the SWF
        
$doc = new DOMDocument();
        if (!@
$doc->loadHTMLFile($url))
            return 
false;
        
        
$xPath = new DOMXpath($doc);
        
        
$mainContainer $doc->getElementById('content3');
        if (empty(
$mainContainer))
            return 
false;
        
        
$objects $mainContainer->getElementsByTagName('embed');
        if (
$objects->length == 0)
            return 
false;
        
        
$object $objects->item(0);
        
        
$type   'wcm';
        
$width  = (int) $object->getAttribute('width');
        
$height = (int) $object->getAttribute('height');
        
$id     str_replace('http://embed.minoto-video.com/42/'''$object->getAttribute('src'));
        
//$width  = 560;
        //$height = 315;
        
        
return true;
    }    
    
// You can implement other video platforms here        
    
    
return false;

If the function returns true, your URL has been identified as a WCM video.

Notice that this script is querying the WCM website, it may return false if WCM is down. Once you have the Minoto ID, width and height, you'll need to cache them (ie in DB or in the code of your post if you are editing a forum). It's a waste of time (and resources) to do this at every page display.

You now have the Minoto ID, the width and height. You just need to craft the embedded player code

PHP Code:
    // Load $type, $id, $width and $height from DB cache
    // If no data in cache, get them by calling the function below and store them
    
detect_video_specs($url$type$id$width$height);
            
    switch(
$type)
    {            
        case 
'wcm':
            return 
'<object width="' $width '" height="' $height '"><param value="http://embed.minoto-video.com/42/' $id '" name="movie">'.
                   
'  <param value="true" name="allowFullScreen" />'.
                   
'  <param value="always" name="allowscriptaccess" />'.
                   
'  <param value="autostart=false" name="FlashVars" />'.
                   
'  <embed width="' $width '" height="' $height '" FlashVars="autostart=false" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://embed.minoto-video.com/42/' $id '">'.
                   
'</object>';            
                
        default:
    } 
"42" seems to be the WCM account id on Minoto.

Last edited by Lenwë Sáralondë : 06-19-2011 at 04:36 PM.
Lenwë Sáralondë is offline   Reply With Quote