简体   繁体   English

使用 AVPlayer swift 4 无法播放某些音频文件

[英]Some audio files are not playing using AVPlayer swift 4

I have 3 remote mp3 files to stream using AVPlayer我有 3 个远程 mp3 文件可以使用 AVPlayer 进行流式传输

File 1 - Meta Data (Worked smoothly)文件 1 - 元数据(工作顺利)

File 2 - Meta Data (Still showing as loading, not working ios but worked in android)文件 2 - 元数据(仍显示为加载,不适用于 ios 但适用于 android)

File 3 - Meta Data (This file is atleast playing something but no playback controls activated like seek, rewind, forward, backward, duration)文件 3 - 元数据(此文件至少正在播放某些内容,但没有激活播放控件,如搜索、倒带、前进、后退、持续时间)

Find meta result here https://drive.google.com/drive/u/0/folders/1mvHGa6iPJba_Bv6NiYzTpwgHTRGHHd7J在此处查找元结果https://drive.google.com/drive/u/0/folders/1mvHGa6iPJba_Bv6NiYzTpwgHTRGHHd7J

This is the code i have implemeted这是我实现的代码

let destinationString = "https://example.com/audio.mp3"
let fileUrl = URL(fileURLWithPath: destinationString)
player = AVPlayer(url:fileUrl)
let vc = AVPlayerViewController()
vc.showsPlaybackControls = true
vc.player = player
self.view.addSubview(vc.view)
self.addChildViewController(vc)
player.play()

Searched a lot for supported file types and content types but doesn't get any relevant result even from apple documentation , Have anybody encountered this issue before ?搜索了很多支持的文件类型和内容类型,但即使从苹果文档中也没有得到任何相关结果,以前有人遇到过这个问题吗?

Totally helpless.完全无助。 Please help me.请帮我。

Thanks in advance.提前致谢。

Try using string init for URL尝试对 URL 使用 string init

let fileUrl = URL(string: destinationString)!

Something to start with.有什么要开始的。 If this does not work try playing those files on your iPhone's safari.如果这不起作用,请尝试在 iPhone 的 safari 上播放这些文件。 If it works then there is something wrong within the app else it could be a server issue.如果它有效,则应用程序中存在问题,否则可能是服务器问题。

At least this will help you debug the issue至少这将帮助您调试问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM