Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zwordi
funkwhale
Commits
f20e83cd
Commit
f20e83cd
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Plain Diff
Merge branch 'player-enhancements' into 'develop'
Player enhancements See merge request
funkwhale/funkwhale!755
parents
3b06cd25
aad2a505
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/music/views.py
+1
-3
1 addition, 3 deletions
api/funkwhale_api/music/views.py
front/src/components/audio/Player.vue
+41
-6
41 additions, 6 deletions
front/src/components/audio/Player.vue
with
42 additions
and
9 deletions
api/funkwhale_api/music/views.py
+
1
−
3
View file @
f20e83cd
...
@@ -323,9 +323,7 @@ def handle_serve(upload, user, format=None, max_bitrate=None):
...
@@ -323,9 +323,7 @@ def handle_serve(upload, user, format=None, max_bitrate=None):
mt
=
f
.
mimetype
mt
=
f
.
mimetype
if
should_transcode
(
f
,
format
,
max_bitrate
=
max_bitrate
):
if
should_transcode
(
f
,
format
,
max_bitrate
=
max_bitrate
):
transcoded_version
=
upload
.
get_transcoded_version
(
transcoded_version
=
f
.
get_transcoded_version
(
format
,
max_bitrate
=
max_bitrate
)
format
,
max_bitrate
=
max_bitrate
)
transcoded_version
.
accessed_date
=
now
transcoded_version
.
accessed_date
=
now
transcoded_version
.
save
(
update_fields
=
[
"
accessed_date
"
])
transcoded_version
.
save
(
update_fields
=
[
"
accessed_date
"
])
f
=
transcoded_version
f
=
transcoded_version
...
...
This diff is collapsed.
Click to expand it.
front/src/components/audio/Player.vue
+
41
−
6
View file @
f20e83cd
...
@@ -254,11 +254,17 @@ export default {
...
@@ -254,11 +254,17 @@ export default {
maxPreloaded
:
3
,
maxPreloaded
:
3
,
preloadDelay
:
15
,
preloadDelay
:
15
,
soundsCache
:
[],
soundsCache
:
[],
soundId
:
null
soundId
:
null
,
playTimeout
:
null
,
nextTrackPreloaded
:
false
}
}
},
},
mounted
()
{
mounted
()
{
this
.
$store
.
dispatch
(
'
player/updateProgress
'
,
0
)
this
.
$store
.
commit
(
'
player/playing
'
,
false
)
this
.
$store
.
commit
(
"
player/isLoadingAudio
"
,
false
)
Howler
.
unload
()
// clear existing cache, if any
Howler
.
unload
()
// clear existing cache, if any
this
.
nextTrackPreloaded
=
false
// we trigger the watcher explicitely it does not work otherwise
// we trigger the watcher explicitely it does not work otherwise
this
.
sliderVolume
=
this
.
volume
this
.
sliderVolume
=
this
.
volume
// this is needed to unlock audio playing under some browsers,
// this is needed to unlock audio playing under some browsers,
...
@@ -273,10 +279,12 @@ export default {
...
@@ -273,10 +279,12 @@ export default {
this
.
getSound
(
this
.
currentTrack
)
this
.
getSound
(
this
.
currentTrack
)
}
}
},
},
d
estroy
ed
()
{
beforeD
estroy
()
{
this
.
dummyAudio
.
unload
()
this
.
dummyAudio
.
unload
()
this
.
observeProgress
(
false
)
this
.
observeProgress
(
false
)
},
},
destroyed
()
{
},
methods
:
{
methods
:
{
...
mapActions
({
...
mapActions
({
togglePlay
:
"
player/togglePlay
"
,
togglePlay
:
"
player/togglePlay
"
,
...
@@ -391,6 +399,7 @@ export default {
...
@@ -391,6 +399,7 @@ export default {
self
.
$store
.
commit
(
'
player/duration
'
,
this
.
duration
())
self
.
$store
.
commit
(
'
player/duration
'
,
this
.
duration
())
},
},
onloaderror
:
function
(
sound
,
error
)
{
onloaderror
:
function
(
sound
,
error
)
{
self
.
removeFromCache
(
this
)
if
(
this
!=
self
.
currentSound
)
{
if
(
this
!=
self
.
currentSound
)
{
return
return
}
}
...
@@ -471,8 +480,9 @@ export default {
...
@@ -471,8 +480,9 @@ export default {
this
.
$store
.
dispatch
(
'
player/updateProgress
'
,
t
)
this
.
$store
.
dispatch
(
'
player/updateProgress
'
,
t
)
this
.
updateBuffer
(
this
.
currentSound
.
_sounds
[
0
].
_node
)
this
.
updateBuffer
(
this
.
currentSound
.
_sounds
[
0
].
_node
)
let
toPreload
=
this
.
$store
.
state
.
queue
.
tracks
[
this
.
currentIndex
+
1
]
let
toPreload
=
this
.
$store
.
state
.
queue
.
tracks
[
this
.
currentIndex
+
1
]
if
(
toPreload
&&
!
this
.
getSoundFromCache
(
toPreload
)
&&
(
t
>
this
.
preloadDelay
||
d
-
t
<
30
))
{
if
(
!
this
.
nextTrackPreloaded
&&
toPreload
&&
!
this
.
getSoundFromCache
(
toPreload
)
&&
(
t
>
this
.
preloadDelay
||
d
-
t
<
30
))
{
this
.
getSound
(
toPreload
)
this
.
getSound
(
toPreload
)
this
.
nextTrackPreloaded
=
true
}
}
}
}
},
},
...
@@ -544,6 +554,17 @@ export default {
...
@@ -544,6 +554,17 @@ export default {
})
})
this
.
soundsCache
=
_
.
reverse
(
toKeep
)
this
.
soundsCache
=
_
.
reverse
(
toKeep
)
},
},
removeFromCache
(
sound
)
{
let
toKeep
=
[]
this
.
soundsCache
.
forEach
((
e
)
=>
{
if
(
e
.
sound
===
sound
)
{
e
.
sound
.
unload
()
}
else
{
toKeep
.
push
(
e
)
}
})
this
.
soundsCache
=
toKeep
},
async
loadSound
(
newValue
,
oldValue
)
{
async
loadSound
(
newValue
,
oldValue
)
{
let
trackData
=
newValue
let
trackData
=
newValue
let
oldSound
=
this
.
currentSound
let
oldSound
=
this
.
currentSound
...
@@ -563,7 +584,9 @@ export default {
...
@@ -563,7 +584,9 @@ export default {
this
.
$store
.
commit
(
'
player/isLoadingAudio
'
,
true
)
this
.
$store
.
commit
(
'
player/isLoadingAudio
'
,
true
)
if
(
this
.
playing
)
{
if
(
this
.
playing
)
{
this
.
soundId
=
this
.
currentSound
.
play
()
this
.
soundId
=
this
.
currentSound
.
play
()
this
.
$store
.
commit
(
'
player/errored
'
,
false
)
this
.
$store
.
commit
(
'
player/playing
'
,
true
)
this
.
$store
.
commit
(
'
player/playing
'
,
true
)
this
.
$store
.
dispatch
(
'
player/updateProgress
'
,
0
)
this
.
observeProgress
(
true
)
this
.
observeProgress
(
true
)
}
}
}
}
...
@@ -659,10 +682,22 @@ export default {
...
@@ -659,10 +682,22 @@ export default {
watch
:
{
watch
:
{
currentTrack
:
{
currentTrack
:
{
async
handler
(
newValue
,
oldValue
)
{
async
handler
(
newValue
,
oldValue
)
{
await
this
.
loadSound
(
newValue
,
oldValue
)
if
(
newValue
===
oldValue
)
{
return
}
this
.
nextTrackPreloaded
=
false
clearTimeout
(
this
.
playTimeout
)
let
self
=
this
if
(
this
.
currentSound
)
{
this
.
currentSound
.
pause
()
}
this
.
$store
.
commit
(
"
player/isLoadingAudio
"
,
true
)
this
.
playTimeout
=
setTimeout
(
async
()
=>
{
await
self
.
loadSound
(
newValue
,
oldValue
)
if
(
!
newValue
||
!
newValue
.
album
.
cover
)
{
if
(
!
newValue
||
!
newValue
.
album
.
cover
)
{
this
.
ambiantColors
=
this
.
defaultAmbiantColors
self
.
ambiantColors
=
self
.
defaultAmbiantColors
}
}
},
500
);
},
},
immediate
:
false
immediate
:
false
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment