File indexing completed on 2024-12-22 04:41:39
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 package org.kde.kdeconnect.Plugins.MprisReceiverPlugin; 0008 0009 import android.media.MediaMetadata; 0010 import android.media.session.MediaController; 0011 import android.media.session.PlaybackState; 0012 import android.os.Build; 0013 0014 import androidx.annotation.Nullable; 0015 import androidx.annotation.RequiresApi; 0016 0017 0018 @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1) 0019 class MprisReceiverCallback extends MediaController.Callback { 0020 0021 private static final String TAG = "MprisReceiver"; 0022 0023 private final MprisReceiverPlayer player; 0024 private final MprisReceiverPlugin plugin; 0025 0026 MprisReceiverCallback(MprisReceiverPlugin plugin, MprisReceiverPlayer player) { 0027 this.player = player; 0028 this.plugin = plugin; 0029 } 0030 0031 @Override 0032 public void onPlaybackStateChanged(PlaybackState state) { 0033 plugin.sendMetadata(player); 0034 } 0035 0036 @Override 0037 public void onMetadataChanged(@Nullable MediaMetadata metadata) { 0038 plugin.sendMetadata(player); 0039 } 0040 0041 @Override 0042 public void onAudioInfoChanged(MediaController.PlaybackInfo info) { 0043 //Note: not called by all media players 0044 plugin.sendMetadata(player); 0045 } 0046 }