2016-09-20 79 views
0

我收到此錯誤播放:(OSStatus錯誤2003334207)從文件

(OSStatus error 2003334207)

嘗試從路徑播放一首歌曲,路徑是有效的,我可以播放從目錄中的MP3,但我不能得到它在音頻播放器中播放,路徑是這樣的 -

file:///XXXX/XXXX/Library/Developer/CoreSimulator/Devices/1ECD7193-872E-4108-A565-F12BED6A69E0/data/Containers/Data/Application/85FD4AD1-54AF-4AD1-81A2-3BDA5CCE9D0A/Documents/Blessings.mp3

let vc = ViewController() 
var myAudioPlayer: AVAudioPlayer = AVAudioPlayer() 

var downloadName = [String]() 
var songDest = [String]() 
var nameMusicFile = String() 
var mp3Url : URL! 

override func viewDidLoad() { 
    super.viewDidLoad() 

    print(downloadName) 
    print(songDest) 
    let convert = URL(fileURLWithPath: songDest[0]) 
    playMusic(url: convert) 
    // Uncomment the following line to preserve selection between presentations 
    // self.clearsSelectionOnViewWillAppear = false 

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem() 
} 


func playMusic(url: URL) { 

    let path = url as URL! 
    do { 


    try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) 

    try AVAudioSession.sharedInstance().setActive(true) 
    try myAudioPlayer = AVAudioPlayer(contentsOf: path!) 
    myAudioPlayer.volume = 1 
    myAudioPlayer.play() 
    } catch let err as NSError{ 
     print(err.localizedDescription) 
    } 
} 

回答

1

,當您試圖訪問其不存在於S中的文件通常會出現此錯誤pecified文件夾或嘗試解開具有nil值的變量。 P1。檢查fetchedResultController是否正在返回一個對象。