本文主要是介绍基于NFC(215芯片)和酷狗音乐实现NFC音乐墙,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前言:
本文方案可以实现直接调起酷狗音乐app自动播放,而非跳转网址
文章目录
- 前言:
- 准备工作:
- 1.获取url
- 2.处理URL
- 3.制作NFC
- 4.效果演示
准备工作:
- nfc tools
- nfc task
- 酷狗音乐APP
- alook浏览器APP
1.获取url
1.选一首歌
2.右上角选择分享,选择复制链接
复制内容为:
分享胡夏的单曲《爱夏》https://t3.kugou.com/song.html?id=13bWedaCJV3 (@酷狗音乐)
只保留网址部分,如下:
https://t3.kugou.com/song.html?id=13bWedaCJV3
3.用alook浏览器打开,
4.点击打开酷狗,拷贝链接
但是酷狗的url太长了,nfc里放不下,所以我们需要删减一部分,
2.处理URL
拷贝链接如下,
kugou://start.weixin?%7B%22cmd%22%3A212%2C%22jsonStr%22%3A%7B%22hash%22%3A%22e4271cb5938f401aa283fbea49223bf8%22%2C%22filename%22%3A%22%E8%8E%AB%E6%96%87%E8%94%9A%20-%20%E9%98%B4%E5%A4%A9%22%2C%22bitrate%22%3A128%2C%22duration%22%3A242%2C%22extname%22%3A%22mp3%22%2C%22privilege%22%3A10%2C%22320privilege%22%3A10%2C%22sqprivilege%22%3A10%2C%22album_audio_id%22%3A32133827%2C%22trans_param%22%3A%7B%22hash_multitrack%22%3A%22A489CA9A6B902F09CF3490D3940C8B53%22%2C%22cpy_grade%22%3A5%2C%22musicpack_advance%22%3A1%2C%22cid%22%3A22181973%2C%22cpy_level%22%3A1%2C%22qualitymap%22%3A%7B%22attr0%22%3A20970548%7D%2C%22ipmap%22%3A%7B%22attr0%22%3A4096%7D%2C%22hash_offset%22%3A%7B%22clip_hash%22%3A%22AB347AAD13337D5D9326C87335A9F3CE%22%2C%22file_type%22%3A0%2C%22start_byte%22%3A0%2C%22start_ms%22%3A0%2C%22offset_hash%22%3A%228762523B893C21BE4C51C4404F944005%22%2C%22end_ms%22%3A60000%2C%22end_byte%22%3A960123%7D%2C%22classmap%22%3A%7B%22attr0%22%3A235016200%7D%2C%22pay_block_tpl%22%3A1%2C%22cpy_attr0%22%3A15488%2C%22display_rate%22%3A2%2C%22appid_block%22%3A%222910%22%2C%22display%22%3A40%2C%22language%22%3A%22%E5%9B%BD%E8%AF%AD%22%7D%2C%22fail_process%22%3A12%2C%22pay_type%22%3A3%2C%22needfav%22%3Afalse%2C%22btnh5%22%3A5%2C%22cyt2%22%3A%22openAppBtn%22%2C%22userid%22%3A%222153285810%22%2C%22chl%22%3A%22link%22%2C%22chl2%22%3A%22%22%2C%22secondShareChl%22%3A%22%22%2C%22vip_share_activity%22%3A%22%22%2C%22p_speed%22%3A%221.0%22%2C%22u%22%3A%222153285810%22%2C%22h1%22%3A%22266240133806765453580375580512035942735%22%2C%22h2%22%3A%22-%22%2C%22cyt1%22%3A%22%E5%85%B6%E4%BB%96%22%2C%22ua_plat%22%3A%22other%22%2C%22page_path%22%3A%22%2Fshare%2F%22%7D%2C%22openBIData%22%3A%7B%22key%22%3A%22d373be6a0f5f62330eedaad97276563e%22%2C%22actid%22%3A%22%22%2C%22kugouid%22%3A0%2C%22url%22%3A%22https%3A%2F%2Fm.kugou.com%2Fshare%2F%22%2C%22ua%22%3A%22mozilla%2F5.0%20(linux%3B%20android%2012%3B%20els-an00%20build%2Fhuaweiels-an00)%20applewebkit%2F537.36%20(khtml%2C%20like%20gecko)%20version%2F4.0%20chrome%2F96.0.4664.104%20mobile%20safari%2F537.36%22%2C%22expand%22%3A%22%22%7D%7D
可以看到有一些乱码,放到chatgpt中转码(应该有别的转码方式,但是我没去进一步的找),因为这段 URL 地址,它采用了 URL 编码。URL 编码是为了在 URL 中安全传输特殊字符而进行的一种转义处理。
提供的 URL 地址经过解码后是:
kugou://start.weixin?{"cmd":212,"jsonStr":{"hash":"d85e2023bc102e9912713a21ec612e56","filename":"曲婉婷 - 我的歌声里","bitrate":128,"duration":216,"extname":"mp3","privilege":8,"320privilege":10,"sqprivilege":10,"album_audio_id":27358902,"trans_param":{"cpy_grade":5,"musicpack_advance":0,"qualitymap":{"attr0":1128251445},"cpy_level":1,"cpy_attr0":64,"ipmap":{"attr0":4096},"cid":32590233,"hash_multitrack":"757CA5E24585DD8D5F0CB9141F25F4D6","pay_block_tpl":1,"classmap":{"attr0":234881032},"display_rate":0,"appid_block":"2906,3124","display":0,"language":"国语","hash_offset":{"start_ms":0}},"fail_process":0,"pay_type":0,"needfav":false,"btnh5":5,"cyt2":"openAppBtn","userid":"2153285810","chl":"link","chl2":"","secondShareChl":"","vip_share_activity":"","u":"2153285810","h1":"266240133806765453580375580512035942735","h2":"-","cyt1":"其他","ua_plat":"other","page_path":"/share/"},"openBIData":{"key":"d373be6a0f5f62330eedaad97276563e","actid":"","kugouid":0,"url":"https://m.kugou.com/share/","ua":"mozilla/5.0 (linux; android 12; els-an00 build/huaweiels-an00) applewebkit/537.36 (khtml, like gecko) version/4.0 chrome/96.0.4664.104 mobile safari/537.36","expand":""}}
这段 JSON 数据包含了一些音频文件的信息,但是实际上我们不需要那么多,删减只保留以下信息即可,这段url是后面要使用的url,
kugou://start.weixin?{"cmd":212,"jsonStr":{"hash":"a280c4836694dfecfb39b9349f6a7c31","filename":"胡夏 - 爱夏","bitrate":128,"duration":271,"extname":"mp3","expand":""}}
3.制作NFC
打开NFC tool,选择添加任务,添加启动应用程序作为第一个任务(酷狗APP),
再添加第二个任务,应用程序中选择添加url,输入刚才获得的url
最后结果如下图所示,
选择写入按钮,将nfc芯片靠到手机的NFC读写处,显示写入成功即可,
4.效果演示
确保手机里有nfc task,手机靠近nfc芯片,即可自动调用酷狗APP并播放。如下所示
这篇关于基于NFC(215芯片)和酷狗音乐实现NFC音乐墙的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!