@@ -266,7 +266,9 @@ var AppView = Backbone.View.extend({
266
266
playItem : function ( item ) {
267
267
var url = 'item/' + item . get ( 'id' ) + '/file' ;
268
268
$ ( '#player audio' ) . attr ( 'src' , url ) ;
269
- $ ( '#player audio' ) . get ( 0 ) . play ( ) ;
269
+ $ ( '#player audio' ) . get ( 0 ) . play ( ) . then ( ( ) => {
270
+ this . updateMediaSession ( item ) ;
271
+ } ) ;
270
272
271
273
if ( this . playingItem != null ) {
272
274
this . playingItem . entryView . setPlaying ( false ) ;
@@ -275,6 +277,26 @@ var AppView = Backbone.View.extend({
275
277
this . playingItem = item ;
276
278
} ,
277
279
280
+ updateMediaSession : function ( item ) {
281
+ if ( "mediaSession" in navigator ) {
282
+ const album_id = item . get ( "album_id" ) ;
283
+ const album_art_url = "album/" + album_id + "/art" ;
284
+ navigator . mediaSession . metadata = new MediaMetadata ( {
285
+ title : item . get ( "title" ) ,
286
+ artist : item . get ( "artist" ) ,
287
+ album : item . get ( "album" ) ,
288
+ artwork : [
289
+ { src : album_art_url , sizes : "96x96" } ,
290
+ { src : album_art_url , sizes : "128x128" } ,
291
+ { src : album_art_url , sizes : "192x192" } ,
292
+ { src : album_art_url , sizes : "256x256" } ,
293
+ { src : album_art_url , sizes : "384x384" } ,
294
+ { src : album_art_url , sizes : "512x512" } ,
295
+ ] ,
296
+ } ) ;
297
+ }
298
+ } ,
299
+
278
300
audioPause : function ( ) {
279
301
this . playingItem . entryView . setPlaying ( false ) ;
280
302
} ,
0 commit comments