我正在开发一个带云存储的ios音乐播放器.
我需要提取音乐信息,如标题,艺术家,艺术品.
我有一个叫做playit的动作,可以播放和暂停mp3文件.它还应该使用与mp3文件关联的metadtaa填充一些UILables和UIImage.问题是我无法从不同的25个mp3文件中提取元数据.这是我的代码:
文件网址是正确的,因为音频播放器能够找到并播放它,但我不知道为什么avmetadataitem无法获取元数据.
- (IBAction)playIt:(id)sender {
AVAudioPlayer *audioPlayer;
AVAsset *assest;
NSString * applicationPath = [[NSBundle mainBundle] resourcePath];
NSString *secondParentPath = [applicationPath stringByDeletingLastPathComponent];
NSString *soundFilePath = [[secondParentPath stringByAppendingPathComponent:@"fisal1407"] stringByAppendingPathComponent:[musicFiles objectForKey:@"show_id"] ];
NSURL *fileURL = [NSURL URLWithString:[soundFilePath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
assest = [AVURLAsset URLAssetWithURL:fileURL options:nil];
NSArray *metadata = [assest commonMetadata];
for (NSString *format in metadata) {
for (AVMetadataItem *item in [assest metadataForFormat:format]) {
if ([[item commonKey] isEqualToString:@"title"]) {
filename.text = (NSString *)[item value];
NSLog(@" title : %@", (NSString *)[item value]);
}
if …Run Code Online (Sandbox Code Playgroud) 我有一些文件,-m4a -mp4 -mp3等我想更改这些细节
AVMetadataItem AVMetadataCommonKeyArtworkAVMetadataCommonKeyArtist 我可以做AVAssetExportSession,但我需要更改目录.有没有办法直接在文件上写?
我找到了这个程序,但不起作用:(
NSError *error;
AVAssetWriter *assetWrtr = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:self.path] fileType:AVFileTypeAppleM4A error:&error];
NSLog(@"%@",error);
NSArray *existingMetadataArray = assetWrtr.metadata;
NSMutableArray *newMetadataArray = nil;
if (existingMetadataArray)
{
newMetadataArray = [existingMetadataArray mutableCopy]; // To prevent overriding of existing metadata
}
else
{
newMetadataArray = [[NSMutableArray alloc] init];
}
AVMutableMetadataItem *item = [[AVMutableMetadataItem alloc] init];
item.keySpace = AVMetadataKeySpaceCommon;
item.key = AVMetadataCommonKeyArtwork;
item.value = UIImagePNGRepresentation([[UIImage alloc] initWithContentsOfFile:[[NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@".image"]]);
[newMetadataArray addObject:item];
assetWrtr.metadata = newMetadataArray; …Run Code Online (Sandbox Code Playgroud) 我正在使用以下命令将 ID3 标签写入文件AVMetaDataItem
var soundFileMetadata = [AVMetadataItem]()
soundFileMetadata.append(createMetadata(AVMetadataiTunesMetadataKeyArtist, "MyArtist")!)
soundFileMetadata.append(createMetadata(AVMetadataiTunesMetadataKeySongName, "MySong")!)
soundFileMetadata.append(createMetadata(AVMetadataiTunesMetadataKeyAlbum, "MyAlbum")!)
soundFileMetadata.append(createMetadata(AVMetadataiTunesMetadataKeyUserGenre, "MyGenre")!)
soundFileMetadata.append(createMetadata(AVMetadataiTunesMetadataKeyComposer, "MyComposer")!)
Run Code Online (Sandbox Code Playgroud)
这是createMetadata方便的方法:
func createMetadata(tagKey: String, _ tagValue: AnyObject?,
keySpace:String = AVMetadataKeySpaceiTunes) -> AVMutableMetadataItem? {
if let tagValue = tagValue {
let tag = AVMutableMetadataItem()
tag.keySpace = keySpace
tag.key = tagKey
tag.value = (tagValue as? String) ?? (tagValue as? Int)
return tag
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试也写年份标签,但没有成功:
let comps = NSDateComponents()
comps.year = 2010;
let yearTag = AVMutableMetadataItem()
yearTag.keySpace = AVMetadataKeySpaceID3
yearTag.key …Run Code Online (Sandbox Code Playgroud) 我已经通过带有AVCaptureMovieFileOutputObject的手机摄像头捕捉视频,
我想将新的元数据添加到文件中,
我尝试使用AVAssetExportSession它,它的工作原理!
但是它花了很多时间,我想,这个方法重新编码了文件,
我只想添加新元(位置),
我尝试使用setMetadata方法AVCaptureMovieFileOutput
但我不知道怎么做,
我试试
元:
AVMutableMetadataItem *newItem = [AVMutableMetadataItem metadataItem];
newItem.identifier = [AVMutableMetadataItem identifierForKey:AVMetadataQuickTimeMetadataKeyLocationISO6709 keySpace:AVMetadataKeySpaceCommon];
newItem.key = AVMetadataQuickTimeMetadataKeyLocationISO6709;
newItem.value = [self gpsStringForVideo:gps];
Run Code Online (Sandbox Code Playgroud)
第一:
[_movieFileOutput setMetadata:@[meta]];
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
Run Code Online (Sandbox Code Playgroud)
但我不能得到代表的回应.
然后:
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
[_movieFileOutput setMetadata:@[meta]];
Run Code Online (Sandbox Code Playgroud)
我可以正常开始录制,但输出文件不包含任何信息!
有人有什么建议吗?谢谢!
我有检测qr代码在哪里的问题.
我需要在它周围画边框.
我使用AVMetadataObject bezierpath,但它不起作用.
请帮我.
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputMetadataObjects:(NSArray *)metadataObjects
fromConnection:(AVCaptureConnection *)connection
{
for (AVMetadataObject *metadata in metadataObjects)
{
AnimationView *cv = [[AnimationView alloc]initWithFrame:self.livevideo.bounds]; //creat an instance of your custom view
[cv setBackgroundColor:[UIColor clearColor]];
NSLog(@"%f",metadata.accessibilityPath.accessibilityActivationPoint.x);
[location addSubview:cv];
if ([metadata.type isEqualToString:AVMetadataObjectTypeEAN13Code])
{
}
else if ([metadata.type isEqualToString:AVMetadataObjectTypeUPCECode])
{
}
else if ([metadata.type isEqualToString:AVMetadataObjectTypeEAN8Code])
{
}
else if ([metadata.type isEqualToString:AVMetadataObjectTypeQRCode])
{
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我正在使用的App设计条形码扫描仪.我希望扫描仪预览能够填满设备的整个屏幕,并提供一个较小的框架来指向条形码.所有的工作都是我想要的,但我不能让感兴趣的框架工作.
这是条形码扫描仪的实现:
#import "GEScannerViewController.h"
@import AVFoundation;
@interface GEScannerViewController () <AVCaptureMetadataOutputObjectsDelegate> {
AVCaptureSession *_session;
AVCaptureDevice *_device;
AVCaptureDeviceInput *_input;
AVCaptureMetadataOutput *_output;
AVCaptureVideoPreviewLayer *_prevLayer;
UIView *_greyView;
UIView *_highlightView;
UIView *_scopeView;
UILabel *_label;
}
@end
@implementation GEScannerViewController
- (void)viewDidLoad {
[super viewDidLoad];
_label = [[UILabel alloc] init];
_label.frame = CGRectMake(0, self.view.bounds.size.height - 40, self.view.bounds.size.width, 40);
_label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
_label.backgroundColor = [UIColor colorWithWhite:0.15 alpha:0.65];
_label.textColor = [UIColor whiteColor];
_label.textAlignment = NSTextAlignmentCenter;
_label.text = @"(none)";
[self.view addSubview:_label];
NSError *error = nil;
_session = [[AVCaptureSession alloc] init]; …Run Code Online (Sandbox Code Playgroud) audio从video文件。< iOS 8.0版本中有效,但在版本中无效>= iOS 8.0。>= iOS 8.0版本中的音频?ios ×5
objective-c ×4
xcode ×2
avasset ×1
avfoundation ×1
ios8 ×1
iphone ×1
metadata ×1
qr-code ×1
swift ×1