我想使用AVAUDIOPLAYER从音频流中检索元数据(歌曲,艺术家)。我尝试使用此代码,但我没有从多个URL获取任何数据。
NSURL *url = [NSURL URLWithString:urlString];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
for (NSString *format in [asset availableMetadataFormats])
有人帮助我吗?也许我做错了? AVAUDIOPLAYER可以做到吗?
谢谢
答案 0 :(得分:0)
以下是如何创建AVAsset
并使用它创建AVPlayerItem
的示例,该AVPlayer
可以与AVAsset
的实例相关联。可以使用var player = AVPlayer()
func createAssetAndItem(){
//create AVAsset from an NSURL. metadata can be retrieved from the asset depending on what is available
let createdAVAsset = AVURLAsset(URL: songNSURL)
//create an AVPlayerItem from the AVAsset
let createdAVItem = AVPlayerItem(asset: createdAVAsset)
//asscoaite AVPlayerItem with instance of AVPlayer
player = AVPlayer(AVPlayerItem: createdAVItem)
}
...
function($stateProvider, $urlRouterProvider, $ocLazyLoadProvider) {
$urlRouterProvider
.otherwise('/app/home');
$stateProvider
.state('app', {
abstract: true,
url: '/app',
templateUrl: "tpl/app.html"
})
.state('app.home', {
url: '/home',
templateUrl: "tpl/home.html",
controller: 'HomeCtrl',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
], {
insertBefore: '#lazyload_placeholder'
})
.then(function() {
return $ocLazyLoad.load([
'assets/js/controllers/home.js'
]);
});
}]
}
})
.state('app.email', {
abstract: true,
url: '/email',
templateUrl: 'tpl/apps/email/email.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'menuclipper',
'wysihtml5'
], {
insertBefore: '#lazyload_placeholder'
})
.then(function() {
return $ocLazyLoad.load([
'assets/js/apps/email/service.js',
'assets/js/apps/email/email.js'
])
});
}]
}
})
.state('app.email.inbox', {
url: '/inbox/:emailId',
templateUrl: 'tpl/apps/email/email_inbox.html'
})
.state('app.email.compose', {
url: '/compose',
templateUrl: 'tpl/apps/email/email_compose.html'
});
}