2017-10-23 23 views
0
playerItem=[AVPlayerItem playerItemWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.radio.com.lk/y-fm/"]]]; 
    player=[AVPlayer playerWithPlayerItem:playerItem] ; 
    [player play]; 

これはシミュレータ上で動作していますが、デバイス内で動作しています。コンソールでは、 は、私は次のエラーを持っている:AVPlayerはシミュレータ上で動作しますが、デバイス上にはありません

CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; "m_Limit" = "m_LimitAll"; "r_Attributes" = 1; sync = syna; }

誰もが手掛かりで私を助けることができますか?

+0

[[AVAudioSession sharedInstance]のsetActive用:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivationエラー:&activationError]; このコードをAppdelegateに追加しましたか? –

+0

こんにちはSambit - 私はそれらを追加しませんでした。私はこれらの2行を追加する必要がありますか? - > [[AVAudioSession sharedInstance] setActive:YES AVAudioSessionSetActiveOptionNotifyOthersOnDeact起動エラー:&activationError]; – HRCJ

+0

どこに追加すればいいのか教えていただけますか? – HRCJ

答えて

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]; 
} 
+0

あなたのコードを説明してください?理由を探す場所が分からなくなったから...ありがとう! – mixable

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]; 
} 
関連する問題