我正在使用react-native-track-player来创建音乐播放器。我正在使用 Youtube API 进行音频流式传输。它给出的 URL 像
https://r2---sn-gwpa-w5py.googlevideo.com/videoplayback?expire=1612552132&ei=ZEMdYNnJDumPz7sPyrSLmAw&ip=49.36.246.217&id=o-AFQLS1cSUJ6_bXBjMOIiWk1NuIYTMUTVu4rmliPZmJCS&itag=251&source=youtube&requiressl=yes&mh=VD&mm=31%2C29&mn=sn-gwpa-w5py%2Csn-gwpa-qxaz&ms=au%2Crdu&mv=m&mvi=2&pl=21&initcwndbps=225000&vprv=1&mime=audio%2Fwebm&ns=nxhNYqBZK92ToigY08JRZjEF&gir=yes&clen=230633&dur=18.961&lmt=1524503096692151&mt=1612530050&fvip=2&keepalive=yes&c=WEB&n=UIc0qqVvrMQOjPVkP&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAObqQA5vFYy6rJ3O3J4zswofNj2NFZOrwMF05p_PgWg9AiAmnde3njBRfvPmW_2VVA0YO1aLWQl0V3STGayuqgBRKA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgFTqy7Ng9zxhQY4GM4vP1BooPeHOf50PTikb59C67voACIGDybTTJBdLkp9lUx_-ZLdCulG_y3TH6iMhBbAn1AZR_&ratebypass=yes
但是 react-native-track-player 仅在 iOS 上不播放来自该 URL 的音频,它在 Android 上完美运行
在 iOS 中,react-native-track-player 最后需要带有 .mp3 扩展名的 URL。我可以将 .mp3 添加到此 URL,或者我应该如何在 iOS 上从该链接播放音频。
我的代码是
TrackPlayer.setupPlayer().then(() => {
console.log('Player set')
});
TrackPlayer.add([{
id: 'trackId1',
url: 'https://r2---sn-gwpa-w5py.googlevideo.com/videoplayback?expire=1612552132&ei=ZEMdYNnJDumPz7sPyrSLmAw&ip=49.36.246.217&id=o-AFQLS1cSUJ6_bXBjMOIiWk1NuIYTMUTVu4rmliPZmJCS&itag=251&source=youtube&requiressl=yes&mh=VD&mm=31%2C29&mn=sn-gwpa-w5py%2Csn-gwpa-qxaz&ms=au%2Crdu&mv=m&mvi=2&pl=21&initcwndbps=225000&vprv=1&mime=audio%2Fwebm&ns=nxhNYqBZK92ToigY08JRZjEF&gir=yes&clen=230633&dur=18.961&lmt=1524503096692151&mt=1612530050&fvip=2&keepalive=yes&c=WEB&n=UIc0qqVvrMQOjPVkP&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAObqQA5vFYy6rJ3O3J4zswofNj2NFZOrwMF05p_PgWg9AiAmnde3njBRfvPmW_2VVA0YO1aLWQl0V3STGayuqgBRKA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgFTqy7Ng9zxhQY4GM4vP1BooPeHOf50PTikb59C67voACIGDybTTJBdLkp9lUx_-ZLdCulG_y3TH6iMhBbAn1AZR_&ratebypass=yes',
title: 'Title',
artist: 'Artist',
artwork: 'https://lh3.googleusercontent.com/jpatCs-PW2LbLWMITjnM9wh5W49QL1c5dhMD3_v6LDZ1okUGgJZIyqp5z4F_Pred10sZlFYjB3Vk6pRE=w1920-h1080-l90-rj'
}]);
TrackPlayer.play();
提前致谢