如何获取在Android设备上播放的音乐曲目的信息?

编程入门 行业动态 更新时间:2024-10-26 14:36:16
本文介绍了如何获取在Android设备上播放的音乐曲目的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想获取在Android设备上播放的音乐曲目的信息. 是否有任何Android驱动的API可用?还是我必须为相应的Android媒体播放器编写插件?

I want to get the Information of the Music track playing on an Android device. Is there any Android-powered API available for this? Or do I have to write a plugin for respective Android media players?

推荐答案

从技术上讲,这是黑客.并且仅适用于与Android捆绑在一起的Music App.

This is technically a hack. And works only with the Music App that comes bundled with Android.

复制此 IMediaPlaybackService. aidl 进入您的项目...请参考此帖子以访问MediaPlayer服务.然后,您可以访问所有这些功能.

Copy this IMediaPlaybackService.aidl into your Project...Refer this Post to access the MediaPlayer Service. You can then access all these functions.

package com.android.music; import android.graphics.Bitmap; interface IMediaPlaybackService { void openFile(String path, boolean oneShot); void openFileAsync(String path); void open(in long [] list, int position); int getQueuePosition(); boolean isPlaying(); void stop(); void pause(); void play(); void prev(); void next(); long duration(); long position(); long seek(long pos); String getTrackName(); String getAlbumName(); long getAlbumId(); String getArtistName(); long getArtistId(); void enqueue(in long [] list, int action); long [] getQueue(); void moveQueueItem(int from, int to); void setQueuePosition(int index); String getPath(); long getAudioId(); void setShuffleMode(int shufflemode); int getShuffleMode(); int removeTracks(int first, int last); int removeTrack(long id); void setRepeatMode(int repeatmode); int getRepeatMode(); int getMediaMountedCount(); }

对于其他播放器,您需要检查他们是否将其服务公开给其他应用程序.

For other players, you'll need to check if they expose their service to other applications.

更多推荐

如何获取在Android设备上播放的音乐曲目的信息?

本文发布于:2023-07-11 09:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093583.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:曲目   设备   音乐   信息   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!