mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-16 18:14:23 +01:00
Draft of playback state broadcast
This commit is contained in:
parent
875875b58c
commit
add845eb23
1 changed files with 15 additions and 3 deletions
|
@ -42,6 +42,7 @@ module.exports = angular.module('ponyfm').factory('player', [
|
||||||
whileplaying: () -> $rootScope.safeApply ->
|
whileplaying: () -> $rootScope.safeApply ->
|
||||||
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
|
||||||
|
broadcastMediaPosition track
|
||||||
|
|
||||||
onload: (res) -> $rootScope.safeApply ->
|
onload: (res) -> $rootScope.safeApply ->
|
||||||
if !res
|
if !res
|
||||||
|
@ -51,6 +52,8 @@ module.exports = angular.module('ponyfm').factory('player', [
|
||||||
show: true
|
show: true
|
||||||
|
|
||||||
onfinish: () -> $rootScope.safeApply ->
|
onfinish: () -> $rootScope.safeApply ->
|
||||||
|
if 'mediaSession' of navigator
|
||||||
|
navigator.mediaSession.setPositionState null
|
||||||
if self.repeatState == 2
|
if self.repeatState == 2
|
||||||
# Track repeat
|
# Track repeat
|
||||||
# Playlist repeat is handled
|
# Playlist repeat is handled
|
||||||
|
@ -63,16 +66,24 @@ module.exports = angular.module('ponyfm').factory('player', [
|
||||||
onstop: () -> $rootScope.safeApply ->
|
onstop: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = false
|
track.isPlaying = false
|
||||||
self.isPlaying = false
|
self.isPlaying = false
|
||||||
|
if 'mediaSession' of navigator
|
||||||
|
navigator.mediaSession.playbackState = "none";
|
||||||
|
|
||||||
onplay: () -> $rootScope.safeApply ->
|
onplay: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = true
|
track.isPlaying = true
|
||||||
broadcastMediaInfo track
|
broadcastMediaInfo track
|
||||||
|
if 'mediaSession' of navigator
|
||||||
|
navigator.mediaSession.playbackState = "playing";
|
||||||
|
|
||||||
onresume: () -> $rootScope.safeApply ->
|
onresume: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = true
|
track.isPlaying = true
|
||||||
|
if 'mediaSession' of navigator
|
||||||
|
navigator.mediaSession.playbackState = "playing";
|
||||||
|
|
||||||
onpause: () -> $rootScope.safeApply ->
|
onpause: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = false
|
track.isPlaying = false
|
||||||
|
if 'mediaSession' of navigator
|
||||||
|
navigator.mediaSession.playbackState = "paused";
|
||||||
|
|
||||||
track.isPlaying = true
|
track.isPlaying = true
|
||||||
self.isPlaying = true
|
self.isPlaying = true
|
||||||
|
@ -107,13 +118,14 @@ module.exports = angular.module('ponyfm').factory('player', [
|
||||||
navigator.mediaSession.setActionHandler(
|
navigator.mediaSession.setActionHandler(
|
||||||
'nexttrack'
|
'nexttrack'
|
||||||
(() -> self.playNext()))
|
(() -> self.playNext()))
|
||||||
|
|
||||||
|
broadcastMediaPosition = (track) ->
|
||||||
|
if 'mediaSession' of navigator
|
||||||
navigator.mediaSession.setPositionState(
|
navigator.mediaSession.setPositionState(
|
||||||
duration: track.duration
|
duration: track.duration
|
||||||
playbackRate: 1
|
playbackRate: 1
|
||||||
position: track.progressSeconds
|
position: track.progressSeconds
|
||||||
);
|
)
|
||||||
|
|
||||||
|
|
||||||
self =
|
self =
|
||||||
ready: false
|
ready: false
|
||||||
|
|
Loading…
Reference in a new issue