Created
May 10, 2013 13:03
-
-
Save meierjan/5554266 to your computer and use it in GitHub Desktop.
Background-Info:
The main problem is the FileSystem method Filesystem::searchByMime() is only searching threw your own Data. Files that are shares with you aren't searched. As my understanding in OwnCloud logic isn't that deep I decided myself to make this "quick and dirty" approach (that is working fine for me).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Workaround for OWNCLOUD that puts SHARED MUSIC into your Player | |
* -> https://github.com/owncloud/apps/issues/855 | |
* | |
* @author: jan1337z <[email protected]> | |
* | |
* -> modifications are made in BASE_FOLDER/apps/media/lib/scanner.php | |
* | |
* To Do (in scanner.php) | |
* 1) Overwrite/Change the getMusic() function with mine below | |
* 2) Add those 2 helper functions: getSharedMusic() & getSharedMusicREK() | |
* 3) change it for your needs | |
* | |
* | |
*/ | |
## IMPORTANT: DO IT AT YOUR OWN RISK - Marked stuff is changed / added ## | |
/** | |
* get a list of all music files of the user | |
* | |
* @return array | |
*/ | |
public function getMusic() { | |
$music = \OC\Files\Filesystem::searchByMime('audio'); | |
$ogg = \OC\Files\Filesystem::searchByMime('application/ogg'); | |
$shared = $this->getSharedMusic("//Shared"); | |
$music = array_merge($music, $ogg,$shared); | |
foreach ($music as &$file) { | |
$file = $file['path']; | |
} | |
return $music; | |
} | |
/** | |
* get a list of all shared music files | |
* @param path to Shared Folder $sharedFolder | |
* @return array | |
*/ | |
public function getSharedMusic($sharedFolderPath) { | |
$sharedFolder = \OC\Files\Filesystem::getDirectoryContent($sharedFolderPath); | |
$files = array(); | |
$this->getSharedMusicREK($sharedFolder,$sharedFolderPath,$files); | |
return $files; | |
} | |
/** | |
* helper function for getSharedMusic | |
* | |
* @return void | |
*/ | |
private function getSharedMusicREK($array,$path,&$files) { | |
foreach($array as $key => $value) { | |
if($value["mimepart"] == 'audio') { | |
$value["path"] = $path."/".$value["name"]; | |
$files[] = $value; | |
continue; | |
} elseif($value["type"] == 'dir') { | |
$this->getSharedMusicREK(\OC\Files\Filesystem::getDirectoryContent($path."/".$value["name"]),$path."/".$value["name"],$files); | |
continue; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can confirm that this hack works. Thx