mirror of
https://github.com/koel/koel
synced 2024-11-24 13:13:05 +00:00
Add CDN support
This commit is contained in:
parent
190c2c117f
commit
3e0c3ab809
5 changed files with 16 additions and 3 deletions
|
@ -28,10 +28,19 @@ APP_MAX_SCAN_TIME=600
|
||||||
# See https://github.com/phanan/koel/wiki#streaming-music for more information.
|
# See https://github.com/phanan/koel/wiki#streaming-music for more information.
|
||||||
STREAMING_METHOD=php
|
STREAMING_METHOD=php
|
||||||
|
|
||||||
|
|
||||||
# If you want Koel to integrate with Last.fm, set the API details here.
|
# If you want Koel to integrate with Last.fm, set the API details here.
|
||||||
LASTFM_API_KEY=
|
LASTFM_API_KEY=
|
||||||
LASTFM_API_SECRET=
|
LASTFM_API_SECRET=
|
||||||
|
|
||||||
|
# You can also configure Koel to use a CDN to serve the media files.
|
||||||
|
# This url must be mapped to the home URL of your Koel's installation.
|
||||||
|
# No trailing slash, please.
|
||||||
|
CDN_URL=
|
||||||
|
|
||||||
|
# The variables below are Laravel-specific.
|
||||||
|
# You can change them if you know what you're doing. Otherwise, just leave them as-is.
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
|
|
|
@ -33,6 +33,7 @@ class DataController extends Controller
|
||||||
'users' => auth()->user()->is_admin ? User::all() : [],
|
'users' => auth()->user()->is_admin ? User::all() : [],
|
||||||
'currentUser' => auth()->user(),
|
'currentUser' => auth()->user(),
|
||||||
'useLastfm' => env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'),
|
'useLastfm' => env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'),
|
||||||
|
'cdnUrl' => trim(env('CDN_URL'), '/ '),
|
||||||
'currentVersion' => Application::VERSION,
|
'currentVersion' => Application::VERSION,
|
||||||
'latestVersion' => auth()->user()->is_admin ? app()->getLatestVersion() : Application::VERSION,
|
'latestVersion' => auth()->user()->is_admin ? app()->getLatestVersion() : Application::VERSION,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -22,7 +22,7 @@ Route::group(['prefix' => 'api', 'namespace' => 'API'], function () {
|
||||||
|
|
||||||
Route::post('settings', 'SettingController@save');
|
Route::post('settings', 'SettingController@save');
|
||||||
|
|
||||||
Route::get('{song}/play', 'SongController@play');
|
Route::get('play/{song}', 'SongController@play');
|
||||||
Route::post('{song}/scrobble/{timestamp}', 'SongController@scrobble')->where([
|
Route::post('{song}/scrobble/{timestamp}', 'SongController@scrobble')->where([
|
||||||
'timestamp' => '\d+',
|
'timestamp' => '\d+',
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
|
||||||
|
import sharedStore from '../stores/shared';
|
||||||
import queueStore from '../stores/queue';
|
import queueStore from '../stores/queue';
|
||||||
import songStore from '../stores/song';
|
import songStore from '../stores/song';
|
||||||
import artistStore from '../stores/artist';
|
import artistStore from '../stores/artist';
|
||||||
|
@ -94,7 +95,7 @@ export default {
|
||||||
|
|
||||||
// Set the song as the current song
|
// Set the song as the current song
|
||||||
queueStore.current(song);
|
queueStore.current(song);
|
||||||
this.player.source(`/api/${song.id}/play?jwt-token=${ls.get('jwt-token')}`);
|
this.player.source(`${sharedStore.state.cdnUrl}/api/play/${song.id}?jwt-token=${ls.get('jwt-token')}`);
|
||||||
|
|
||||||
// We'll just "restart" playing the song, which will handle notification, scrobbling etc.
|
// We'll just "restart" playing the song, which will handle notification, scrobbling etc.
|
||||||
this.restart();
|
this.restart();
|
||||||
|
@ -187,7 +188,7 @@ export default {
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceStore.set('repeatMode', this.repeatModes[i]);
|
preferenceStore.set('repeatMode', this.repeatModes[i]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,7 @@ export default {
|
||||||
useLastfm: false,
|
useLastfm: false,
|
||||||
currentVersion: '',
|
currentVersion: '',
|
||||||
latestVersion: '',
|
latestVersion: '',
|
||||||
|
cdnUrl: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
init(successCb = null, errorCb = null) {
|
init(successCb = null, errorCb = null) {
|
||||||
|
@ -63,5 +64,6 @@ export default {
|
||||||
this.state.useLastfm = false;
|
this.state.useLastfm = false;
|
||||||
this.state.currentVersion = '';
|
this.state.currentVersion = '';
|
||||||
this.state.latestVersion = '';
|
this.state.latestVersion = '';
|
||||||
|
this.state.cdnUrl = '';
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue