BlueZ MediaPlayer轨迹位置未与手机同步

时间:2019-04-21 10:06:32

标签: bluetooth bluez a2dp

我已将Android手机与Ubuntu 18.04.1配对,并在手机上播放音乐(a2dp源)。我可以在Ubuntu(a2dp接收器)上听音乐,使用BlueZ的dbusmedia api将命令发送到电话(例如Play / Pause / Next等),还可以获取曲目信息(标题,持续时间,跟踪位置等)

问题:如果我当前正在2:10播放持续时间为5分钟的歌曲,则dbus查询会为我提供大约130000ms的正确位置,但是如果我手动更改电话的位置以假设为2:30,则dbus查询仍然显示大约130-140k ms的时间,这意味着它正在根据上次同步自行计算位置,并且没有意识到手机所做的任何更改。但是,如果我暂停并再次播放,该位置将再次同步并显示正确的位置。

dbus查询:

    dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_44_C3_46_7B_2D_C7/player0 org.freedesktop.DBus.Properties.Get string:"org.bluez.MediaPlayer1" string:"Position"

我决定与Windows 10 a2dp sink player进行交叉核对,但是电话中音轨位置的变化会立即反映到播放器窗口中。 我尝试使用以下方法监控dbus信号:

dbus-monitor --system "type='signal', sender='org.bluez'"

这是输出:

dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "Rejected send message, 1 matched rules; type="method_call", sender=":1.246" (uid=1000 pid=8991 comm="dbus-monitor --system type='signal', sender='org.b" label="unconfined") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.
signal time=1555847560.121045 sender=org.freedesktop.DBus -> destination=:1.246 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.246"
signal time=1555847570.624003 sender=:1.161 -> destination=(null destination) serial=32467 path=/org/bluez/hci0/dev_44_C3_46_7B_2D_C7/fd1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.MediaTransport1"
   array [
      dict entry(
         string "State"
         variant             string "pending"
      )
   ]
   array [
   ]
signal time=1555847570.625959 sender=:1.161 -> destination=(null destination) serial=32469 path=/org/bluez/hci0/dev_44_C3_46_7B_2D_C7/fd1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.MediaTransport1"
   array [
      dict entry(
         string "State"
         variant             string "active"
      )
   ]
   array [
   ]
signal time=1555847570.662250 sender=:1.161 -> destination=(null destination) serial=32470 path=/org/bluez/hci0/dev_44_C3_46_7B_2D_C7/player0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.MediaPlayer1"
   array [
      dict entry(
         string "Status"
         variant             string "playing"
      )
   ]
   array [
   ]
signal time=1555847570.723943 sender=:1.161 -> destination=(null destination) serial=32471 path=/org/bluez/hci0/dev_44_C3_46_7B_2D_C7/player0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.MediaPlayer1"
   array [
      dict entry(
         string "Position"
         variant             uint32 148405
      )
   ]
   array [
   ]

仅在执行“播放/暂停/下一个/上一个”之类的操作时才确认触发PropertiesChanged信号,而在电话上更改位置时则不这样做。
我可以随时使用BlueZ api本身使BlueZ发出PropertiesChanged信号吗?

0 个答案:

没有答案