[vlc-commits] [Git][videolan/vlc][master] macosx: expose live status and artwork to the OS

Jean-Baptiste Kempf gitlab at videolan.org
Wed Jun 16 06:12:11 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
9b77a171 by Felix Paul Kühne at 2021-06-16T05:40:08+00:00
macosx: expose live status and artwork to the OS

- - - - -


1 changed file:

- modules/gui/macosx/os-integration/VLCRemoteControlService.m


Changes:

=====================================
modules/gui/macosx/os-integration/VLCRemoteControlService.m
=====================================
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * VLCRemoteControlService.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2017-2019 VLC authors and VideoLAN
+ * Copyright (C) 2017-2021 VLC authors and VideoLAN
  *
  * Authors: Carola Nitz <nitz.carola # gmail.com>
  *          Felix Paul Kühne <fkuehne # videolan.org>
@@ -157,7 +157,22 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
     currentlyPlayingTrackInfo[MPMediaItemPropertyArtist] = inputItem.artist;
     currentlyPlayingTrackInfo[MPMediaItemPropertyAlbumTitle] = inputItem.albumName;
     currentlyPlayingTrackInfo[MPMediaItemPropertyAlbumTrackNumber] = @([inputItem.trackNumber intValue]);
-    currentlyPlayingTrackInfo[MPMediaItemPropertyPlaybackDuration] = @(SEC_FROM_VLC_TICK(inputItem.duration));
+
+    vlc_tick_t duration = inputItem.duration;
+    currentlyPlayingTrackInfo[MPMediaItemPropertyPlaybackDuration] = @(SEC_FROM_VLC_TICK(duration));
+    currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyIsLiveStream] = @(duration <= 0);
+
+    NSURL *artworkURL = inputItem.artworkURL;
+    if (artworkURL) {
+        NSImage *coverArtImage = [[NSImage alloc] initWithContentsOfURL:artworkURL];
+        if (coverArtImage) {
+            MPMediaItemArtwork *mpartwork = [[MPMediaItemArtwork alloc] initWithBoundsSize:coverArtImage.size
+                                                                            requestHandler:^NSImage* _Nonnull(CGSize size) {
+                return coverArtImage;
+            }];
+            currentlyPlayingTrackInfo[MPMediaItemPropertyArtwork] = mpartwork;
+        }
+    }
 
     [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = currentlyPlayingTrackInfo;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9b77a1719856c9da8c8c2db3b347e1026f957362

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9b77a1719856c9da8c8c2db3b347e1026f957362
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list