Skip to content

Commit

Permalink
loading status, robust scanner, execution time, CSS
Browse files Browse the repository at this point in the history
 * visualize loading state
 * make scanner more robust and fix PHP errors
 * disable execution time for rescan
 * realign playerbar content and adding whitespace (ref #80)
  • Loading branch information
MorrisJobke committed Sep 5, 2013
1 parent ddb3149 commit fc5881a
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 27 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>Music player and server for ownCloud</description>
<licence>AGPLv3</licence>
<author>Morris Jobke</author>
<version>0.1.3-alpha</version>
<version>0.1.4-alpha</version>
<require>5</require>
<types>
<!-- update metadata cache when create/update/delete a file -->
Expand Down
2 changes: 1 addition & 1 deletion appinfo/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.3-alpha
0.1.4-alpha
13 changes: 5 additions & 8 deletions css/style-playerbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}

#play-controls {
/*margin-left: 50px; first release fix*/
margin-left: 40px; /* with sidebar 50px */
}

#playerbar .control.small {
Expand All @@ -73,8 +73,7 @@

#playerbar .albumart {
position: absolute;
/*left: 300px; first release fix*/
left: 150px;
left: 213px; /* with sidebar 300px */
top: 0;
height: 50px;
width: 50px;
Expand All @@ -90,8 +89,7 @@
max-width: 400px;
position: absolute;
top: 0;
/*left: 400px; first release fix*/
left: 250px;
left: 313px; /* with sidebar 400px */
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
Expand All @@ -111,9 +109,8 @@
#playerbar .progress-info {
width: 300px;
position: absolute;
top: 10px;
/*left: 830px; first release fix*/
right: 140px;
top: 7px;
left: 620px; /* with sidebar 830px */
text-align: center;
}

Expand Down
6 changes: 3 additions & 3 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

#app-content.started {
padding-top: 66px;
padding-top: 50px;
}

.play {
Expand All @@ -30,7 +30,7 @@
}

.artist-area {
padding: 28px 0;
padding-top: 50px;
clear: both;
}

Expand All @@ -51,7 +51,7 @@
}

.album-area {
padding: 28px;
padding: 14px 28px;
width: 480px;
float: left;
}
Expand Down
9 changes: 8 additions & 1 deletion js/app/controllers/maincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@


angular.module('Music').controller('MainController',
['$scope', '$routeParams', 'Artists', 'playlistService', function ($scope, $routeParams, Artists, playlistService) {
['$rootScope', '$scope', '$routeParams', 'Artists', 'playlistService',
function ($rootScope, $scope, $routeParams, Artists, playlistService) {

// will be invoked by the artist factory
$rootScope.$on('artistsLoaded', function() {
$scope.loading = false;
});

$scope.loading = true;
$scope.artists = Artists;

$scope.playTrack = function(track) {
Expand Down
8 changes: 6 additions & 2 deletions js/app/factories/artists.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
*
*/

angular.module('Music').factory('Artists', ['Restangular', function (Restangular) {
return Restangular.all('artists').getList({fulltree: true});
angular.module('Music').factory('Artists', ['Restangular', '$rootScope', function (Restangular, $rootScope) {
return Restangular.all('artists').getList({fulltree: true}).then(
function(result){
$rootScope.$emit('artistsLoaded');
return result;
});
}]);
17 changes: 14 additions & 3 deletions js/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ angular.module('Music', ['restangular']).

}]);
angular.module('Music').controller('MainController',
['$scope', '$routeParams', 'Artists', 'playlistService', function ($scope, $routeParams, Artists, playlistService) {
['$rootScope', '$scope', '$routeParams', 'Artists', 'playlistService',
function ($rootScope, $scope, $routeParams, Artists, playlistService) {

// will be invoked by the artist factory
$rootScope.$on('artistsLoaded', function() {
$scope.loading = false;
});

$scope.loading = true;
$scope.artists = Artists;

$scope.playTrack = function(track) {
Expand Down Expand Up @@ -282,8 +289,12 @@ angular.module('Music').directive('albumart', function() {
});
};
});
angular.module('Music').factory('Artists', ['Restangular', function (Restangular) {
return Restangular.all('artists').getList({fulltree: true});
angular.module('Music').factory('Artists', ['Restangular', '$rootScope', function (Restangular, $rootScope) {
return Restangular.all('artists').getList({fulltree: true}).then(
function(result){
$rootScope.$emit('artistsLoaded');
return result;
});
}]);

angular.module('Music').factory('Audio', function () {
Expand Down
7 changes: 5 additions & 2 deletions templates/part.main.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div ng-hide="artists" id="emptystate">{{ trans('Nothing in here. Upload your music!') }}</div>
<div ng-hide="artists" id="emptystate">
<span ng-hide="loading">{{ trans('Nothing in here. Upload your music!') }}</span>
<span ng-show="loading">{{ trans('Loading ...') }}</span>
</div>

<div class="artist-area" ng-repeat="artist in artists | orderBy:'name'">
<h1 ng-click="playArtist(artist)">[[ artist.name ]] <img class="play svg" alt="{{ trans('Play') }}" src="{{ image_path('actions/play-big.svg', 'core') }}" /></h1>
Expand All @@ -24,4 +27,4 @@ <h2 ng-click="playAlbum(album)" title="[[ album.name ]] ([[ album.year]])">[[ al
ng-hide="limit == 5">{{ trans('Show less ...') }}</li>
</ul>
</div>
</div>
</div>
35 changes: 29 additions & 6 deletions utility/scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,30 @@ public function update($path){
if(ini_get('allow_url_fopen')) {
$fileInfo = $this->extractor->extract('oc://' . $this->api->getView()->getAbsolutePath($path));

/*if(!array_key_exists('comments', $fileInfo)) {
$hasComments = array_key_exists('comments', $fileInfo);
/*if(!$hasComments) {
$this->api->log('"comments" is empty ' . $path . ' # ' . $this->api->getView()->getAbsolutePath($path), 'debug');
return;
}*/

$userId = $this->api->getUserId();

// artist
$artist = array_key_exists('artist', $fileInfo['comments']) ? $fileInfo['comments']['artist'][0] : null;
$artist = null;
if($hasComments && array_key_exists('artist', $fileInfo['comments'])){
$artist = $fileInfo['comments']['artist'][0];
}
if($artist === null || $artist === ''){
// fallback to "ownCloud unknown artist"
$artist = 'ownCloud unknown artist';
}

$alternativeTrackNumber = null;
// title
$title = array_key_exists('title', $fileInfo['comments']) ? $fileInfo['comments']['title'][0] : null;
$title = null;
if($hasComments && array_key_exists('title', $fileInfo['comments'])){
$title = $fileInfo['comments']['title'][0];
}
if($title === null || $title === ''){
// fallback to file name
$title = $metadata['name'];
Expand All @@ -101,22 +108,31 @@ public function update($path){
}

// album
$album = array_key_exists('album', $fileInfo['comments']) ? $fileInfo['comments']['album'][0] : null;
$album = null;
if($hasComments && array_key_exists('album', $fileInfo['comments'])){
$album = $fileInfo['comments']['album'][0];
}
if($album === null || $album === ''){
// fallback to "ownCloud unknown album"
$album = 'ownCloud unknown album';
}

// track number
$trackNumber = array_key_exists('track_number', $fileInfo['comments']) ? $fileInfo['comments']['track_number'][0] : null;
$trackNumber = null;
if($hasComments && array_key_exists('track_number', $fileInfo['comments'])){
$trackNumber = $fileInfo['comments']['track_number'][0];
}
if($trackNumber === null && $alternativeTrackNumber !== null) {
$trackNumber = $alternativeTrackNumber;
}
// convert track number '1/10' to '1'
$tmp = explode('/', $trackNumber);
$trackNumber = $tmp[0];

$year = array_key_exists('year', $fileInfo['comments']) ? $fileInfo['comments']['year'][0] : null;
$year = null;
if($hasComments && array_key_exists('year', $fileInfo['comments'])){
$year = $fileInfo['comments']['year'][0];
}
$mimetype = $metadata['mimetype'];
$fileId = $metadata['fileid'];

Expand Down Expand Up @@ -171,11 +187,18 @@ public function delete($path){
* Rescan the whole file base for new files
*/
public function rescan() {
// get execution time limit
$executionTime = intval(ini_get('max_execution_time'));
// set execution time limit to unlimited
set_time_limit(0);

$music = $this->api->searchByMime('audio');
$ogg = $this->api->searchByMime('application/ogg');
$music = array_merge($music, $ogg);
foreach ($music as $file) {
$this->update($file['path']);
}
// reset execution time limit
set_time_limit($executionTime);
}
}

0 comments on commit fc5881a

Please sign in to comment.