automatically scan songs that are played from the filebrowser
This commit is contained in:
parent
f88b477459
commit
cbf8f822de
|
@ -107,6 +107,19 @@ if($arguments['action']){
|
||||||
case 'get_songs':
|
case 'get_songs':
|
||||||
echo json_encode(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search']));
|
echo json_encode(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search']));
|
||||||
break;
|
break;
|
||||||
|
case 'get_path_info':
|
||||||
|
$songId=OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
|
||||||
|
if($songId==0){
|
||||||
|
unset($_SESSION['collection']);
|
||||||
|
$songId= OC_MEDIA_SCANNER::scanFile($arguments['path']);
|
||||||
|
}
|
||||||
|
if($songId>0){
|
||||||
|
$song=OC_MEDIA_COLLECTION::getSong($songId);
|
||||||
|
$song['artist']=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
|
||||||
|
$song['album']=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
|
||||||
|
echo json_encode($song);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'play':
|
case 'play':
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,12 @@ var PlayList={
|
||||||
},
|
},
|
||||||
addFile:function(path){
|
addFile:function(path){
|
||||||
var type=musicTypeFromFile(path);
|
var type=musicTypeFromFile(path);
|
||||||
var item={name:'unknown',artist:'unknown',album:'unknwon',type:type};//todo get song data
|
var item={name:'unknown',artist:'unknown',album:'unknwon',type:type};
|
||||||
|
$.getJSON(OC.filePath('media','ajax','api.php')+'?action=get_path_info&path='+encodeURIComponent(path),function(song){
|
||||||
|
item.name=song.song_name;
|
||||||
|
item.artist=song.artist;
|
||||||
|
item.album=song.album;
|
||||||
|
});
|
||||||
item[type]=PlayList.urlBase+encodeURIComponent(path);
|
item[type]=PlayList.urlBase+encodeURIComponent(path);
|
||||||
PlayList.items.push(item);
|
PlayList.items.push(item);
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,7 +38,6 @@ class OC_MEDIA_SCANNER{
|
||||||
* @return int the number of songs found
|
* @return int the number of songs found
|
||||||
*/
|
*/
|
||||||
public static function scanFolder($path){
|
public static function scanFolder($path){
|
||||||
// OC_DB::beginTransaction();
|
|
||||||
if (OC_Filesystem::is_dir($path)) {
|
if (OC_Filesystem::is_dir($path)) {
|
||||||
$songs=0;
|
$songs=0;
|
||||||
if ($dh = OC_Filesystem::opendir($path)) {
|
if ($dh = OC_Filesystem::opendir($path)) {
|
||||||
|
@ -62,7 +61,6 @@ class OC_MEDIA_SCANNER{
|
||||||
}else{
|
}else{
|
||||||
$songs=0;
|
$songs=0;
|
||||||
}
|
}
|
||||||
// OC_DB::commit();
|
|
||||||
return $songs;
|
return $songs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +139,6 @@ class OC_MEDIA_SCANNER{
|
||||||
$albumId=self::$albums[$artist.'/'.$album];
|
$albumId=self::$albums[$artist.'/'.$album];
|
||||||
}
|
}
|
||||||
$songId=OC_MEDIA_COLLECTION::addSong($title,$path,$artistId,$albumId,$length,$track,$size);
|
$songId=OC_MEDIA_COLLECTION::addSong($title,$path,$artistId,$albumId,$length,$track,$size);
|
||||||
return !($title=='unkown' && $artist=='unkown' && $album=='unkown');
|
return (!($title=='unkown' && $artist=='unkown' && $album=='unkown'))?$songId:0;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue