gpt4 book ai didi

ios - 在 UIImagePicker 和 UISaveVideoAtPathToSavedPhotosAlbum 之后找到 mediaPath

转载 作者:行者123 更新时间:2023-11-28 22:30:02 24 4
gpt4 key购买 nike

我有一个图像选择器,我可以在其中选择一部电影(可以编辑)。然后我使用抓取缩略图;

UIImage *tempImage = [moviePlayerThumb thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

这项工作很好,我可以用另一种方法显示图像,没问题。我还存储视频数据以供稍后上传;

[mediaDict setValue:[NSData dataWithContentsOfFile:mediaPath] forKey:@"data"];

这也适用于上传文件后从服务器播放没有问题。

我存储的最后一件事是 URL 和路径,但是,当我稍后将它们放入播放器时,我会卡在播放器说“正在加载”(加上旋转的东西);

我认为这是因为编辑后的选择器将视频存储在一个临时目录中,该目录(稍后我播放文件时)已被清空。

路径是这样的;

file://localhost/private/var/mobile/Applications/B26A085A-C471-4972-9070-5A3F8DC48449/tmp//trim.ttCbAg.MOV

我试图让选择器像这样永久存储视频;

    NSString *mediaPath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

NSURL *mediaURL=[info objectForKey:UIImagePickerControllerMediaURL];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (mediaPath))
{
UISaveVideoAtPathToSavedPhotosAlbum (mediaPath, nil, nil, nil);
}

我知道这是有效的,因为我的相册正在慢慢填满我的视频的编辑版本。问题是如何在 UISaveVideo 方法之后找出文件的路径?

播放器记录这个;

[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
[MPAVController] Autoplay: Enabling autoplay

播放器代码如下所示(我试过使用 mediaPath 和 mediaURL);

    // Play the movie
NSURL *tempMediaPath = [NSURL fileURLWithPath:images[indexPath.item][@"path"]];

NSURL *tempMediaURL = images[indexPath.item][@"URL"];

NSLog(@"Media Path, URL : %@, %@", tempMediaPath, tempMediaURL);

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:tempMediaPath];

[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer prepareToPlay];
[moviePlayer play];

还有 NSLog;

Media Path, URL : file://localhost/private/var/mobile/Applications/B26A085A-C471-4972-9070-5A3F8DC48449/tmp//trim.ttCbAg.MOV, file://localhost/private/var/mobile/Applications/B26A085A-C471-4972-9070-5A3F8DC48449/tmp//trim.ttCbAg.MOV

非常感谢任何帮助。

最佳答案

我在另一个项目中做了同样的事情,下面的代码在嵌入式模式和全屏模式下都有效:

_movieController = [[MPMoviePlayerController alloc] initWithContentURL:self.movieURL];
_movieController.view.frame = self.view.bounds;
_movieController.controlStyle = MPMovieControlStyleEmbedded;
_movieController.backgroundView.hidden = YES;
_movieController.contentURL = self.movieURL;
[_movieController prepareToPlay];
_movieController.scalingMode = MPMovieScalingModeAspectFit;
_movieController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_movieController.shouldAutoplay=YES;
_movieController.movieSourceType = MPMovieSourceTypeFile;
[self.view addSubview:_movieController.view];

关于ios - 在 UIImagePicker 和 UISaveVideoAtPathToSavedPhotosAlbum 之后找到 mediaPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17681002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com