有没有办法在 Android 上获取歌曲播放次数/最近播放的歌曲?
我想知道是否有任何方法可以访问 Android 上最常播放/最近播放的歌曲或歌曲的播放次数?我尝试过使用 MediaStore 从内容解析器获取信息,但没有找到任何内容。虽然里面有很多东西,所以我可能错过了一些东西。我还查看了 MediaMetadataRetriever,但我也看不到任何内容。查看维基百科显示 ID3v2 标签可以包含播放计数器,但这可以通过 Android 访问吗?
I'm wondering if there's any way to access the top played/recently played songs, or play counts for songs on Android? I've had a look at getting information from a content resolver using the MediaStore
, but I haven't found anything. There's a lot in there though, so I may have missed something. I've also looked at MediaMetadataRetriever
, but I can't see anything there either. Looking at Wikipedia shows that ID3v2 tags can contain a play counter, but is this accessible through Android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一个链接,说应该可以使用 id3标签库。
FrameBodyPCNT
是您需要使用 id3 标签库中的播放计数器类。Here is a link that says it should be possible using the id3 tag library.
The
FrameBodyPCNT
is the play counter class you need use from the id3 tag library.作为部分答案,我在玩这个时确实有一个想法,使用
lastModified()
方法(因为我将所有歌曲作为File
进行浏览)无论如何)。这个功能实际上最终被废弃了,所以我没有测试它,但是使用lastModified()
并获取那些具有最高值的歌曲应该会给你最新播放/添加的歌曲(正如我'我猜测每次播放时 ID3 标签都会略有改变,特别是当有播放计数器时)。不过,我会再等一段时间,看看其他人是否能提出一些建议。
As a partial answer, I did have an idea while I was playing around with this, to use the
lastModified()
method (as I was going through all the songs asFile
s anyway). This functionality actually got scrapped in the end, so I didn't test it, but usinglastModified()
and taking those songs with the highest value should give you the latest played/added songs (as I'm guessing the ID3 tags would be slightly altered with each play, especially as there is the play counter).However, I'm going to wait a little longer to see if anyone else comes up with something.