相关疑难解决方法(0)

iOS 8中每次启动时的文档或缓存路径更改

当我在我的应用程序中下载视频并将其保存在本地缓存/文档路径中并在必要时显示.它在iOS 7中工作,但是avplayer没有在iOS 8及更高版本中显示视频.正如我已经读到的那样,iOS 8中的每次启动都会更改文档/缓存路径.问题是,我必须下载一次视频并在我的应用程序中多次显示.那么我怎么能一次又一次地到达相同的路径来在应用程序中显示视频.

Here is my code:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// NSLog(@"Document folder: %@", paths);
NSString *documentsDirectory = [paths objectAtIndex:0];
   NSLog(@"Document folder: %@", documentsDirectory);
Run Code Online (Sandbox Code Playgroud)

在日志中,每次启动时都会有不同的路径.任何帮助,将不胜感激.谢谢

ios ios8 ios8.1

13
推荐指数
2
解决办法
3914
查看次数

使用AVAudioPlayer时OSStatus错误2003334207

当按下按钮时,我正在尝试播放MP3文件(当通过VLC/iTunes播放时起作用).这是我的代码:

     var audioPlayer: AVAudioPlayer!
     @IBAction func playEpisode(sender: AnyObject) {
    println("now playing")
    let indexPath = NSIndexPath(forRow: sender.tag, inSection: 0)
    let data: CDEpisode = fetchedResultsController.objectAtIndexPath(indexPath!) as! CDEpisode
    var err: NSError?
    let url = NSURL(string: data.localPath)
    println("The url is \(url)")

    audioPlayer = AVAudioPlayer(contentsOfURL: url, error: &err)
    if audioPlayer == nil {
        if let e = err {
            println(e.localizedDescription)
        }
    }
    audioPlayer.delegate = self
    audioPlayer.prepareToPlay()
    audioPlayer.play()
}
Run Code Online (Sandbox Code Playgroud)

这是日志:

now playing
The url is Optional(file:///var/mobile/Containers/Data/Application/4747A71E-A63F-4EFC-B2DF-8B361361080B/Documents/serial-s01-e12.mp3)
The operation couldn’t be completed. (OSStatus error 2003334207.)
fatal error: …
Run Code Online (Sandbox Code Playgroud)

avaudioplayer ios swift

10
推荐指数
3
解决办法
1万
查看次数

标签 统计

ios ×2

avaudioplayer ×1

ios8 ×1

ios8.1 ×1

swift ×1