Example #1
0
             if ($songId > 0) {
                 $song = $collection->getSong($songId);
                 $song['artist'] = $collection->getArtistName($song['song_artist']);
                 $song['album'] = $collection->getAlbumName($song['song_album']);
                 \OCP\JSON::encodedPrint($song);
             }
         }
         break;
     case 'play':
         $ftype = \OC\Files\Filesystem::getMimeType($arguments['path']);
         if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') {
             echo 'Not an audio file';
             exit;
         }
         $songId = $collection->getSongByPath($arguments['path']);
         $collection->registerPlay($songId);
         header('Content-Type:' . $ftype);
         \OCP\Response::enableCaching(3600 * 24);
         // 24 hour
         header('Accept-Ranges: bytes');
         header('Content-Length: ' . \OC\Files\Filesystem::filesize($arguments['path']));
         $mtime = \OC\Files\Filesystem::filemtime($arguments['path']);
         \OCP\Response::setLastModifiedHeader($mtime);
         \OC\Files\Filesystem::readfile($arguments['path']);
         exit;
     case 'find_music':
         $scanner = new Scanner($collection);
         $music = $scanner->getMusic();
         \OCP\JSON::encodedPrint($music);
         exit;
 }