private function Playlist::get_media_files in MediaFront 7
Same name and namespace in other branches
- 6.2 players/osmplayer/player/playlist/Playlist.php \Playlist::get_media_files()
- 6 players/osmplayer/player/playlist/Playlist.php \Playlist::get_media_files()
Recursive directory searcher to locate any media and image files within any given path.
Parameters
- The path where to start your search.:
- The files array.:
- Used to keep track of the current folder when recursing.:
1 call to Playlist::get_media_files()
- Playlist::getPlaylist in players/
osmplayer/ player/ playlist/ Playlist.php - Returns the playlist in XML form.
File
- players/
osmplayer/ player/ playlist/ Playlist.php, line 289
Class
- Playlist
- Playlist Class
Code
private function get_media_files($path, &$files, $folder = 0) {
// Only continue if this is a directory.
if (is_dir($path)) {
// Open the directory.
if ($contents = opendir($path)) {
// Iterate through all the files in this directory.
while (($node = readdir($contents)) !== false) {
// Make sure this is not the parent or current directory elements.
if ($node != "." && $node != "..") {
// Cache the full node path.
$node = $path . '/' . $node;
// If this node is a directory, then we will want to recurse.
$directory = is_dir($node);
if ($directory) {
// Get the index of this directory and recurse.
$index = substr($node, $this->folderLength) - 1;
$this
->get_media_files($node, $files, $index);
}
else {
if (!$directory) {
// If this is not a directory, then we need to add it to our files list.
$extension = $this
->get_file_ext($node);
if (in_array($extension, $this->mediaTypes)) {
$files[$folder]['media'][] = $node;
}
else {
if (in_array($extension, $this->imageTypes)) {
$files[$folder]['image'] = $node;
}
}
}
}
}
}
}
}
}