菜鸟教程小白 发表于 2022-12-11 18:05:02

ios - 如何在 iOS 的 iPod 库中获取歌曲的文件位置


                                            <p><p>当用户从 iPod 库中选择音频时,我有一个 <code>MPMediaItem</code> 的引用。我正在使用</p>获取该项目的 <code>asset url</code>

<pre><code>   let url = item.valueForProperty(MPMediaItemPropertyAssetURL)
</code></pre>

<p>但这并没有给我文件的确切物理位置,而是给我一个 url w.r.t iPod 库。</p>

<pre><code>ipod-library://item/item.mp3?id=1840064795502796074
</code></pre>

<p>有没有办法从 iPod 库中获取歌曲的 <code>物理 url</code>?</p>

<p>编辑 - 实际上我想从物理文件中提取 <code>NSData</code> 并将其发送到我的 <code>后端服务器</code>,所以我需要物理文件 URL 而不是相对 URL</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>由于版权保护,您只能播放音乐库中的歌曲。您无法访问行音频文件!但是有一些技巧可以提供帮助,例如您可以 <code>export music</code> 因为您可以混合类型的东西,并且在创建新的编辑文件后,您会获得音乐文件的新副本,您可以将其发送给我,但不能像您发送照片和视频一样直接从图书馆发送!你必须先用 <code>export session</code> 导出它!</p>

<p>请参阅 <a href="https://stackoverflow.com/questions/11364997/pick-music-from-ios-library-and-send-save" rel="noreferrer noopener nofollow">this so post</a>为此!</p>

<p>您应该引用 <a href="https://developer.apple.com/library/content/samplecode/AddMusic/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008845-Intro-DontLinkElementID_2" rel="noreferrer noopener nofollow">Apple sample code for that</a> </p>

<p>还有 <a href="https://stackoverflow.com/questions/8077725/application-crashed-while-importing-songs-from-ipod-library-in-iphone-for-ios-5" rel="noreferrer noopener nofollow">this so post</a>和 <a href="http://iphoneghostrider.blogspot.in/2014/05/import-music-and-save-it-to-document.html" rel="noreferrer noopener nofollow">this tutoria</a>也可能对你有帮助!</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 iOS 的 iPod 库中获取歌曲的文件位置,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/40624473/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/40624473/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 iOS 的 iPod 库中获取歌曲的文件位置