AVPlayer dostał metadane, ale nie grał
Próbuję wykonać bardzo prostą aplikację, celem jest słuchanie strumienia audio (AAC 64 kbps). Aby to zrobić, używamAVPlayer
zApple AVFoundation
nastąpił:
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize playerItem, player;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://stream.myjungly.fr/MYJUNGLY2"]];
[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];
player = [AVPlayer playerWithPlayerItem:playerItem];
[player play];
NSLog(@"player item error : %@", playerItem.error.description);
NSLog(@"player error : %@", player.error.description);
}
- (void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object
change:(NSDictionary*)change context:(void*)context {
if ([keyPath isEqualToString:@"timedMetadata"])
{
AVPlayerItem* _playerItem = object;
for (AVMetadataItem* metadata in _playerItem.timedMetadata)
{
NSLog(@"\nkey: %@\nkeySpace: %@\ncommonKey: %@\nvalue: %@", [metadata.key description], metadata.keySpace, metadata.commonKey, metadata.stringValue);
}
}
}
@end
Mój obiektplayer
iplayerItem
sąsilny nieruchomości :
ViewController.h
@interface ViewController : UIViewController
@property (nonatomic, strong) AVPlayerItem* playerItem;
@property (nonatomic, strong) AVPlayer* player;
@end
Key Value Observer działa świetnie, oto mój dziennik:
2013-05-14 11:18:03.725 MusicAvPlayer[6494:907] player item error : (null)
2013-05-14 11:18:03.728 MusicAvPlayer[6494:907] player error : (null)
2013-05-14 11:18:08.140 MusicAvPlayer[6494:907]
key: title
keySpace: comn
commonKey: title
value: Alabama Shakes - Be Mine
Ale dźwięk nie jest odtwarzany, nie słychać dźwięku! Jakiś pomysł dlaczego?
EDYTOWAĆ: Patrzę już na te pytania:
AVAudioPlayer nie odtwarza żadnego dźwięku
Dlatego używam silnej własności, więc myślę, że mój problem nie jest związany z ARC