Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class flvdata extends obj

Helix obj flvdata
Hide Inherited MembersVideo Gallery
Description
No description.
 
Constants
No constants.
 
Properties
protected_aspect[ flvdata ]
protected_dirty[ obj ]
protected_duration[ flvdata ]
protected_flvtool2_output[ flvdata ]
protected_height[ flvdata ]
protected_keyframes[ flvdata ]
protected_num_keyframes[ flvdata ]
publicproperty_objects_array[ obj ]
protected_width[ flvdata ]
 
Methods
public__construct ( path , resource )[ flvdata ]
Parameters
optionalpath
optionalresource
Code
012  public function __construct($__path=null, $__resource=null)
013  {
014      if (!is_null($__path))
015      {
016          $path = $__path;
017      }
018      else if (!is_null($__resource))
019      {
020          $path = $__resource->path;
021      }
022      else
023      {
024          $path = null;
025      }
026      $command = 'flvtool2 -xP "' . $path . '"';
027      $this->_flvtool2_output = `$command`;
028     
029      $xml = new SimpleXMLElement($this->_flvtool2_output);
030     
031      foreach ($xml->flv->keyframes->times->value as $time)
032      {
033          $this->_keyframes["times"][] = (float)$time;
034      }
035      foreach ($xml->flv->keyframes->filepositions->value as $fileposition)
036      {
037          $this->_keyframes["filepositions"][] = (float)$fileposition;
038      }
039      $this->height = (int)$xml->flv->height;
040      $this->width = (int)$xml->flv->width;
041      $this->duration = (float)$xml->flv->duration;
042     
043  //        list($this->_keyframes["times"], $this->_keyframes["filepositions"]) = $this->_strip_keyframes_from_raw_output();
044      $this->aspect = ($this->width>0 && $this->height>0) ? ($this->width/$this->height) : (4/3);
045  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_num_keyframes ( )[ flvdata ]
Parameters
No parameters for this method
Code
113  public function get_num_keyframes()
114  {
115      return count($this->_keyframes["times"]);
116  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
private_strip_keyframes_from_raw_output ( )[ flvdata ]
Parameters
No parameters for this method
Code
047  private function _strip_keyframes_from_raw_output()
048  {
049      $lines = preg_split('/\n/i',$this->_flvtool2_output);
050      $times = array();
051      $filepositions = array();
052      $reading_times = false;
053      $found_keyframe_start = false;
054      $found_keyframe_time_start = false;
055      $found_keyframe_fileposition_start = false;
056      foreach ($lines as $index=>$line)
057      {
058          $data = trim($line);
059          if (preg_match('/height:\s+([0-9]+)/i',$data,$height_matches))
060          {
061              $this->height = $height_matches[1];
062          }
063          if (preg_match('/width:\s+([0-9]+)/i',$data,$width_matches))
064          {
065              $this->width = $width_matches[1];
066          }
067          if (preg_match('/^keyframes/i',$data))
068          {
069              $found_keyframe_start = true;
070              continue;
071          }
072          if ($found_keyframe_start)
073          {
074              if (preg_match('/^times/i',$data))
075              {
076                  $found_keyframe_time_start = true;
077                  continue;
078              }
079              if ($found_keyframe_time_start)
080              {
081                  if (preg_match('/- ([0-9]+(\.[0-9]+)?)/i',$data,$matches))
082                  {
083                      $times[] = $matches[1];
084                  }
085                  else
086                  {
087                      $found_keyframe_time_start = false;
088                  }
089              }
090             
091              if (preg_match('/^filepositions/i',$data))
092              {
093                  $found_keyframe_fileposition_start = true;
094                  continue;
095              }
096              if ($found_keyframe_fileposition_start)
097              {
098                  if (preg_match('/- ([0-9]+)/i',$data,$matches))
099                  {
100                      $filepositions[] = $matches[1];
101                  }
102                  else
103                  {
104                      $found_keyframe_fileposition_start = false;
105                      $found_keyframe_start = false;
106                  }
107              }
108          }
109      }
110      return array($times, $filepositions);
111  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicnum_keyframes[ flvdata ]
Code
113  public function get_num_keyframes()
114  {
115      return count($this->_keyframes["times"]);
116  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads