<i id='r3pgy'><tr id='r3pgy'><dt id='r3pgy'><q id='r3pgy'><span id='r3pgy'><b id='r3pgy'><form id='r3pgy'><ins id='r3pgy'></ins><ul id='r3pgy'></ul><sub id='r3pgy'></sub></form><legend id='r3pgy'></legend><bdo id='r3pgy'><pre id='r3pgy'><center id='r3pgy'></center></pre></bdo></b><th id='r3pgy'></th></span></q></dt></tr></i><div id='r3pgy'><tfoot id='r3pgy'></tfoot><dl id='r3pgy'><fieldset id='r3pgy'></fieldset></dl></div>

    <tfoot id='r3pgy'></tfoot>
      <bdo id='r3pgy'></bdo><ul id='r3pgy'></ul>

    <small id='r3pgy'></small><noframes id='r3pgy'>

  1. <legend id='r3pgy'><style id='r3pgy'><dir id='r3pgy'><q id='r3pgy'></q></dir></style></legend>
    1. 如何从资产网址保存视频

      How to save video from assets url(如何从资产网址保存视频)
        <tbody id='dDaDM'></tbody>
      <legend id='dDaDM'><style id='dDaDM'><dir id='dDaDM'><q id='dDaDM'></q></dir></style></legend>
      <i id='dDaDM'><tr id='dDaDM'><dt id='dDaDM'><q id='dDaDM'><span id='dDaDM'><b id='dDaDM'><form id='dDaDM'><ins id='dDaDM'></ins><ul id='dDaDM'></ul><sub id='dDaDM'></sub></form><legend id='dDaDM'></legend><bdo id='dDaDM'><pre id='dDaDM'><center id='dDaDM'></center></pre></bdo></b><th id='dDaDM'></th></span></q></dt></tr></i><div id='dDaDM'><tfoot id='dDaDM'></tfoot><dl id='dDaDM'><fieldset id='dDaDM'></fieldset></dl></div>
      • <bdo id='dDaDM'></bdo><ul id='dDaDM'></ul>

            <tfoot id='dDaDM'></tfoot>

              • <small id='dDaDM'></small><noframes id='dDaDM'>

                本文介绍了如何从资产网址保存视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想从资产 url 将视频保存到我的应用文档中.我的资产网址如下:-

                "assets-library://asset/asset.MOV?id=1000000394&ext=MOV"

                我试过这个:-

                NSString *str=@"assets-library://asset/asset.MOV?id=1000000394&ext=MOV";NSData *videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];[videoData writeToFile:mypath atomically:YES];

                但是在第二行 [NSData dataWithContentsOfURL:[NSURL URLWithString:str]] 我得到了程序崩溃的原因:-由于未捕获的异常NSInvalidArgumentException"而终止应用,原因:'-[NSURL 长度]:无法识别的选择器已发送到实例

                我想知道如何访问资产视频网址.

                感谢任何帮助.

                解决方案

                我认为你最好的办法是使用方法

                getBytes:fromOffset:length:error:

                ALAssetRepresentation

                你可以像这样获得资产的默认表示

                ALAssetRepresentation *representation = [someVideoAsset defaultRepresentation];

                所以我想它应该是这样的(我不在我的 Mac 上,所以这个还没有经过测试)

                ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];[assetLibraryassetForURL:videoUrl resultBlock:^(ALAsset *asset) {ALAssetRepresentation *rep = [资产 defaultRepresentation];字节 *buffer = (Byte*)malloc(rep.size);NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];[数据 writeToFile:filePath atomically:YES];} 错误块:^(NSError *err){NSLog(@"错误: %@",[错误的本地化描述]);}];

                videoUrl 是您要复制的视频的资产 url,filePath 是您要保存的路径.p>

                I want to save video to my app document from asset url. My asset url is as follows:-

                "assets-library://asset/asset.MOV?id=1000000394&ext=MOV"
                

                I tried this:-

                NSString *str=@"assets-library://asset/asset.MOV?id=1000000394&ext=MOV";
                NSData *videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
                [videoData writeToFile:mypath atomically:YES];
                

                but on the second line [NSData dataWithContentsOfURL:[NSURL URLWithString:str]] i got program crash with this reason:- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL length]: unrecognized selector sent to instance

                I want to know how to access asset video url.

                Thanx for any help.

                解决方案

                I think your best bet is to use the method

                getBytes:fromOffset:length:error:
                

                of

                ALAssetRepresentation
                

                You can get the default representation of an asset like so

                ALAssetRepresentation *representation = [someVideoAsset defaultRepresentation];
                

                So off the top of my head it should go something like this (I'm away from my Mac so this hasn't been tested)

                ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
                [assetLibrary assetForURL:videoUrl resultBlock:^(ALAsset *asset) {
                    ALAssetRepresentation *rep = [asset defaultRepresentation];
                    Byte *buffer = (Byte*)malloc(rep.size);
                    NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
                    NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
                    [data writeToFile:filePath atomically:YES];
                } errorBlock:^(NSError *err) {
                    NSLog(@"Error: %@",[err localizedDescription]);
                }];
                

                Where videoUrl is the asset url of the video you're trying to copy, and filePath is the path where you're trying to save it to.

                这篇关于如何从资产网址保存视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                How to add and get the values from .plist in iOS(如何在 iOS 中从 .plist 添加和获取值)
                Mobile Device Management with iPhone(使用 iPhone 进行移动设备管理)
                <i id='gnSY0'><tr id='gnSY0'><dt id='gnSY0'><q id='gnSY0'><span id='gnSY0'><b id='gnSY0'><form id='gnSY0'><ins id='gnSY0'></ins><ul id='gnSY0'></ul><sub id='gnSY0'></sub></form><legend id='gnSY0'></legend><bdo id='gnSY0'><pre id='gnSY0'><center id='gnSY0'></center></pre></bdo></b><th id='gnSY0'></th></span></q></dt></tr></i><div id='gnSY0'><tfoot id='gnSY0'></tfoot><dl id='gnSY0'><fieldset id='gnSY0'></fieldset></dl></div>
                  <tbody id='gnSY0'></tbody>

                  <legend id='gnSY0'><style id='gnSY0'><dir id='gnSY0'><q id='gnSY0'></q></dir></style></legend>
                    <bdo id='gnSY0'></bdo><ul id='gnSY0'></ul>

                    1. <tfoot id='gnSY0'></tfoot>

                      <small id='gnSY0'></small><noframes id='gnSY0'>