Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Michael A. Peters  >  Embed Media  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Demonstration php script
Class: Embed Media
Generate HTML to embed audio and video players
Author: By
Last change:
Date: 5 years ago
Size: 2,867 bytes
 

Contents

Class file image Download
<html>
<head><title>Example Code</title></head><body>
<h1>
Initiation the class:</h1>
<?php
// search and replace arrays below only needed to put generated code in pre block
//  for demonstrative purposes
$search[]='/</';
$search[]='/>/';
$replace[]='&lt;';
$replace[]='&gt;';
//
require_once('extend.embedMedia.inc');
$foo = new DOMDocument("1.0","UTF-8");
$foo->preserveWhiteSpace false;
$foo->formatOutput true;
$media = new embedSDVideo($foo,'myVid','/media/myvid.mp4','/media/myvid.ogv','/media/myvid.wmv');
$mObject $media->auto();
$foo->appendChild($mObject);
?>
<pre>
&lt;?php
require_once('extend.embedMedia.inc');
$foo = new DOMDocument("1.0","UTF-8");
$foo->preserveWhiteSpace = false;
$foo->formatOutput = true;
$media = new embedSDVideo($foo,'myVid','/media/myvid.mp4','/media/myvid.ogv','/media/myvid.wmv');
$mObject = $media->auto();
$foo->appendChild($mObject);
?&gt;
</pre>

<p>
Note that I am using the extended class so that I do not need to define all the public variables, they are defined in embedSDVideo which extends embedMedia for standard definition video.</p>

<h2>Generating HTML Fragment</h2>
<?php
$string 
preg_replace('/<\/source>/','',$foo->saveHTML());
?>
<pre>
&lt;?php
$string = preg_replace('/<\/source>/','',$foo->saveHTML());
print ($string);
?&gt;
</pre>
<p>
Produces the following output:</p>
<pre>
<?php
$ex_string 
preg_replace($search,$replace,$string);
print(
$ex_string);
?>
</pre>

<h2>Generating XHTML Fragment</h2>
<?php
$string 
preg_replace('/.+\n/','',$foo->saveXML(),1);
?>
<pre>
&lt;?php
$string = preg_replace('/.+\n/','',$foo->saveXML(),1);
print ($string);
?&gt;
</pre>
<p>
Produces the following output:</p>
<pre>
<?php
$ex_string 
preg_replace($search,$replace,$string);
print(
$ex_string);
?>
</pre>

<h2>Generating Windows Media XHTML Fragment</h2>
<p>
Since IE currently technically only supports html normally we would be generating HTML but the formatting of XHTML produced by DOMDocument is better, so for demonstrative purposes, here it is as XHTML.</p>
<?php
$foo 
= new DOMDocument("1.0","UTF-8");
$foo->preserveWhiteSpace false;
$foo->formatOutput true;
$media = new embedSDVideo($foo,'myVid','/media/myvid.mp4','/media/myvid.ogv','/media/myvid.wmv');
$mObject $media->windowsMedia();
$foo->appendChild($mObject);
$string preg_replace('/.+\n/','',$foo->saveXML(),1);
?>
<pre>
&lt;?php
$foo = new DOMDocument("1.0","UTF-8");
$foo->preserveWhiteSpace = false;
$foo->formatOutput = true;
$media = new embedSDVideo($foo,'myVid','/media/myvid.mp4','/media/myvid.ogv','/media/myvid.wmv');
$mObject = $media-&gt;windowsMedia();
$foo->appendChild($mObject);
$string = preg_replace('/.+\n/','',$foo->saveXML(),1);
print ($string);
?&gt;
</pre>
<p>
Produces the following output:</p>
<pre>
<?php
$ex_string 
preg_replace($search,$replace,$string);
print(
$ex_string);
?>
</pre>

</body></html>