UIVideoAtPathIsCompatibleWithSavedPhotosAlbum在iPhone上部署时返回false [英] UIVideoAtPathIsCompatibleWithSavedPhotosAlbum returns false when deploying on the iPhone

查看:1757
本文介绍了UIVideoAtPathIsCompatibleWithSavedPhotosAlbum在iPhone上部署时返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个应用程序的功能是下载mp4文件并将其存储到本地电话簿。

One of my app's features is to download a mp4 file and store it to the local phone album.

我已经尝试了几种方法,结果总是相同的,它在模拟器上工作,但不在实际的iPhone上。 Xcode是版本5.0.1,iPhone 4。

I have tried several approaches since and the result is always the same, it worked on the simulator but not on the actual iPhone. Xcode is version 5.0.1, iPhone 4.

以下是我在使用ASIHttpRequest库发布之前最后一次尝试的代码,结果仍然是一样的在模拟器上工作,但不是手机本身。

Below is the code I applied on the last attempt before posted here using ASIHttpRequest library and the result is still the same, it worked on the simulator but not the phone itself.


  1. 下载:

  1. download:

ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:url]; // url is the address to the mp4 file

NSString* filePath = [NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), filename]; //filename is the file I save to, e.g. xxx.mp4

[request setDownloadDestinationPath:filePath];
[request setDelegate:self];
[request setDidFinishSelector:@selector[ASIRequestDone:)];
[request setDidFailSelector:@select[ASIRequestFail:)];


  • 下载完成后,保存到相册(在$ code > ASIRequestDone 委托)

  • when download is finished, save it to the photo album (in ASIRequestDone delegate)

    if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filePath))
    {
        //comes to here when running in simulators
        UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, @selector(video:didFinishSavingWithError:cotextInfo:),nil);
    } 
    else 
    {
        //always comes to here when running on the actual iPhone.
    }
    


  • pathFile这是这个

    I have checked the pathFile it's this

    /private/var/mobile/Applications/xxxxxxxxxx/tmp/xxxxx.mp4
    

    对我来说是好的。我没有得到的是在模拟器上运行时工作正常,因此我不知道接下来要做什么。 (我也检查过权限访问相册,是的应用程序有)。

    which is alright to me. What I am not getting is it works fine when running on Simulator and hence I am stuck not sure what to do next. (I have also checked the permission accessing the the photo albums and yes the app has it).

    我也试图删除兼容检查,直接进入方法 UISaveVideoAtPathToSavedPhotosAlbum ,它没有在委托 didFinishSavingWithError 上抛出任何错误。但是,视频没有显示在相册上,我猜这是正确的,因为手机似乎说视频不兼容,以在相册上显示。再次,我的问题是它在模拟器上工作,如何解决这个问题在实际的iphone,例如为什么它认为视频不兼容?与mp4本身有关,还是下载步骤中要做的事情?下一步可以做什么来解决问题? (ps。我也可以控制mp4文件,有没有你知道的iphone上的mp4兼容性列表?我想也许这是真的,该文件是不兼容的手机(但在模拟器上?))

    I also tried to removed the compatible checking and went straight into the method UISaveVideoAtPathToSavedPhotosAlbum, it didn't throw any error on delegate didFinishSavingWithError. however, the video didn't show up on the photo album either, I am guessing it's correct as the phone seems to say that video is not compatible to be shown on the album. Again, my issue is that it does work on the simulator and how do I fix this on the actual iphone, e.g. why it thinks the video is not compatible? is something to do with the mp4 itself or is it something to do during the download step? What could I do next to resolve the issue? (ps. I also have control over the mp4 files, is there a list of mp4 compatibility on the iphone that you know? I am thinking perhaps it's genuine that the file is not compatible on the phone (but on the simulator!?))

    推荐答案

    找到我的问题的答案,希望能帮助那些患有同样问题的人。事实上,视频分辨率是模拟器和实际手机之间的因素,当将视频存储到画廊时;具体如下:

    Found the answer to my question and I hope it could help out someone who suffers from the same issue. Turns out video resolution is the factor between the simulator and the actual phone when it comes to store video to the gallery; to be specific:

    兼容性检查UIVideoAtPathIsCompatibleWithSavedPhotosAlbum将在实际手机上失败,但会在模拟器上给予一个示例剪辑capturrd为1080p的PASS。我的邮箱在一周之后,我就来过这个链接。

    Compatibility checking UIVideoAtPathIsCompatibleWithSavedPhotosAlbum would FAIL on the actual phone but would PASS on the simulator given a sample clip capturrd as 1080p. I came cross this link a week after my post with luck.

    什么视频格式与资产库兼容?

    我做了实验类似于通过捕获720p视频剪辑,所有文件都能够保存到画廊。奇怪的是,实际的iphone可以播放1080p的HLS流;除非它们是720p,否则它不会存储剪辑,而不是我。而误导的一点是模拟器实际上可以做到1080p。

    And I did the experiment similar to that by capturing 720p video clips instead and all files were able to be saved to the gallery. Weird thing is that the actual iphone can play the HLS stream at 1080p; howeve it won't store clips unless they are 720p, not to me anyway. And the misleading bit is that the simulator can actually do 1080p.

    这篇关于UIVideoAtPathIsCompatibleWithSavedPhotosAlbum在iPhone上部署时返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆