playerItem=[AVPlayerItem playerItemWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.radio.com.lk/y-fm/"]]];
player=[AVPlayer playerWithPlayerItem:playerItem] ;
[player play];
它正在使用模拟器,但在设备中,它不是。在控制台中, 我有以下错误:
CredStore - performQuery - 复制匹配的信息时出错。 错误= -25300,query = { class = inet; “m_Limit”=“m_LimitAll”; “r_Attributes”= 1; sync = syna; }
任何人都可以帮我一个线索吗?
答案 0 :(得分:2)
请在您的应用代表中添加以下代码。它可能会帮助你
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&activationError];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&setCategoryError];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}
答案 1 :(得分:1)
我的回答是给你的
ViewController.h
#import <UIKit/UIKit.h>
#import <AVKit/AVKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) AVPlayerViewController *playerViewController;
@property (nonatomic,strong)AVAudioPlayer *player;
- (IBAction)actionPlay:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize player;
@synthesize playerViewController;
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)actionPlay:(id)sender {
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:yourURL];
AVPlayer* playVideo = [[AVPlayer alloc] initWithPlayerItem:playerItem];
playerViewController = [[AVPlayerViewController alloc] init];
playerViewController.player = playVideo;
playerViewController.player.volume = 0;
playerViewController.view.frame = self.view.bounds;
[self.view addSubview:playerViewController.view];
[playVideo play];
}