mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Added dialog for track load errors
This commit is contained in:
parent
141282e8c7
commit
e5c9ff3e71
3 changed files with 43 additions and 14 deletions
|
@ -114,11 +114,16 @@ class TracksController extends Controller
|
|||
}
|
||||
|
||||
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
|
||||
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
|
||||
|
||||
$response = Response::make('', 200);
|
||||
$filename = $trackFile->getFile();
|
||||
|
||||
if (!file_exists($filename)) {
|
||||
App::abort(418);
|
||||
}
|
||||
|
||||
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
|
||||
|
||||
if (Config::get('app.sendfile')) {
|
||||
$response->header('X-Sendfile', $filename);
|
||||
} else {
|
||||
|
|
17
public/templates/partials/track-load-fail-dialog.html
Normal file
17
public/templates/partials/track-load-fail-dialog.html
Normal 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()">×</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>
|
|
@ -15,8 +15,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module.exports = angular.module('ponyfm').factory('player', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
'$rootScope', '$http', '$modal'
|
||||
($rootScope, $http, $modal) ->
|
||||
readyDef = new $.Deferred()
|
||||
|
||||
play = (track) ->
|
||||
|
@ -43,6 +43,13 @@ module.exports = angular.module('ponyfm').factory('player', [
|
|||
track.progressSeconds = self.currentSound.position / 1000
|
||||
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 ->
|
||||
if self.repeatState == 2
|
||||
# Track repeat
|
||||
|
@ -169,6 +176,8 @@ module.exports = angular.module('ponyfm').factory('player', [
|
|||
self.ready = true
|
||||
self.setVolume($.cookie('pfm-volume') || 100)
|
||||
|
||||
readyDef.resolve()
|
||||
|
||||
codeArray = []
|
||||
codeKey = '38,38,40,40,37,39,37,39,66,65'
|
||||
$(document).keydown (e) ->
|
||||
|
@ -176,11 +185,9 @@ module.exports = angular.module('ponyfm').factory('player', [
|
|||
if codeArray.toString().indexOf(codeKey) >= 0
|
||||
$http.get('https://pony.fm/api/web/tracks/23453').success (trackResponse) =>
|
||||
toPlay = trackResponse.track
|
||||
play(toPlay)
|
||||
self.playTracks [toPlay], 0
|
||||
codeArray = []
|
||||
return
|
||||
|
||||
readyDef.resolve()
|
||||
|
||||
self
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue