Added dialog for track load errors

This commit is contained in:
Josef Citrine 2016-10-01 18:20:49 +01:00
parent 141282e8c7
commit e5c9ff3e71
3 changed files with 43 additions and 14 deletions

View file

@ -114,11 +114,16 @@ class TracksController extends Controller
} }
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension); $trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
$response = Response::make('', 200); $response = Response::make('', 200);
$filename = $trackFile->getFile(); $filename = $trackFile->getFile();
if (!file_exists($filename)) {
App::abort(418);
}
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
if (Config::get('app.sendfile')) { if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename); $response->header('X-Sendfile', $filename);
} else { } else {

View file

@ -0,0 +1,17 @@
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" ng-show="title">
<button type="button" class="close" ng-click="$hide()">&times;</button>
<h4 class="modal-title">Failed to load track</h4>
</div>
<div class="modal-body">
<p>This track is not available. It may still be processing. Please check back in a few minutes.</p>
<p>If you're still getting this error after 30 minutes, please email <a href="mailto:logic@pony.fm">logic@pony.fm</a></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click="$hide()">Ok</button>
</div>
</div>
</div>
</div>

View file

@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
module.exports = angular.module('ponyfm').factory('player', [ module.exports = angular.module('ponyfm').factory('player', [
'$rootScope', '$http' '$rootScope', '$http', '$modal'
($rootScope, $http) -> ($rootScope, $http, $modal) ->
readyDef = new $.Deferred() readyDef = new $.Deferred()
play = (track) -> play = (track) ->
@ -43,6 +43,13 @@ module.exports = angular.module('ponyfm').factory('player', [
track.progressSeconds = self.currentSound.position / 1000 track.progressSeconds = self.currentSound.position / 1000
track.progress = (self.currentSound.position / (track.duration * 1000)) * 100 track.progress = (self.currentSound.position / (track.duration * 1000)) * 100
onload: (res) -> $rootScope.safeApply ->
if !res
# Track failed to load
dialog = $modal
templateUrl: '/templates/partials/track-load-fail-dialog.html',
show: true
onfinish: () -> $rootScope.safeApply -> onfinish: () -> $rootScope.safeApply ->
if self.repeatState == 2 if self.repeatState == 2
# Track repeat # Track repeat
@ -169,6 +176,8 @@ module.exports = angular.module('ponyfm').factory('player', [
self.ready = true self.ready = true
self.setVolume($.cookie('pfm-volume') || 100) self.setVolume($.cookie('pfm-volume') || 100)
readyDef.resolve()
codeArray = [] codeArray = []
codeKey = '38,38,40,40,37,39,37,39,66,65' codeKey = '38,38,40,40,37,39,37,39,66,65'
$(document).keydown (e) -> $(document).keydown (e) ->
@ -176,11 +185,9 @@ module.exports = angular.module('ponyfm').factory('player', [
if codeArray.toString().indexOf(codeKey) >= 0 if codeArray.toString().indexOf(codeKey) >= 0
$http.get('https://pony.fm/api/web/tracks/23453').success (trackResponse) => $http.get('https://pony.fm/api/web/tracks/23453').success (trackResponse) =>
toPlay = trackResponse.track toPlay = trackResponse.track
play(toPlay) self.playTracks [toPlay], 0
codeArray = [] codeArray = []
return return
readyDef.resolve()
self self
]) ])