欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

IOS藍(lán)牙語音通信

 最近看了不少關(guān)于ios藍(lán)牙語音通信的文章,網(wǎng)上錯誤不少。最近自己寫了個小Demo。

10年積累的成都做網(wǎng)站、網(wǎng)站設(shè)計經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有南山免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

具體的每個函數(shù)干什么的請自行查詢。都是Gamekit框架的api。

代碼實現(xiàn)如下

- (void)viewDidLoad

{

    [superviewDidLoad];

    CGSize size=[[UIScreen mainScreen] bounds].size;

    

   UIButton *muteBtn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    [muteBtnsetTitle:@"聊天中"forState:UIControlStateHighlighted];

    [muteBtnsetTitle:@"聊天"forState:UIControlStateNormal];

    [muteBtn setFrame:CGRectMake(size.width/2.0-140.0, 20, 280, 280)];

    [muteBtnaddTarget:selfaction:@selector(muteAction:)forControlEvents:UIControlEventTouchDown];

    [muteBtnaddTarget:selfaction:@selector(UnmuteAction:)forControlEvents:UIControlEventTouchUpInside];

    

   UIButton *connectBtn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    [connectBtnsetTitle:@"連接"forState:UIControlStateNormal];

    [connectBtn setFrame:CGRectMake(size.width/2.0-50.0, 320, 100, 40)];

    [connectBtnaddTarget:selfaction:@selector(connectAction:)forControlEvents:UIControlEventTouchUpInside];

    

    

   UIButton *disConnectBtn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    [disConnectBtn setTitle:@"斷開連接" forState:UIControlStateNormal];

    [disConnectBtn setFrame:CGRectMake(size.width/2.0-50.0, 380, 100, 40)];

    [disConnectBtnaddTarget:selfaction:@selector(disConnectAction:)forControlEvents:UIControlEventTouchUpInside];

     [self.view addSubview:muteBtn];

    [self.view addSubview:connectBtn];

    [self.view addSubview:disConnectBtn];

}

 

-(void)connectAction:(id)sender{

    if (!picker) {

       picker=[[GKPeerPickerControlleralloc]init];

       picker.connectionTypesMask=GKPeerPickerConnectionTypeNearby;

        picker.delegate=self;

    }

    if (!isConnect) {

        [picker show];

    }

}

 

-(GKSession *)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type{

    if (!_session) {

       _session=[[GKSessionalloc]initWithSessionID:(_sessionID ?_sessionID :@"Sample Session")displayName:nilsessionMode:GKSessionModePeer];

        _session.delegate=self;

    }

return_session;

}

 

-(void)peerPickerController:(GKPeerPickerController *)picker1 didConnectPeer:(NSString *)peerID toSession:(GKSession *)session{

    

    [picker dismiss];

   isConnect=YES;

    [_sessionsetDataReceiveHandler:selfwithContext:nil];

    NSError *error;

    

   AVAudioSession *audioSession=[AVAudioSessionsharedInstance];

    

   if (![audioSessionsetCategory:AVAudioSessionCategoryPlayAndRecorderror:&error]) {

       NSLog(@"設(shè)置播放記錄錯誤:%@",[errorlocalizedDescription]);

        return;

    }

    if (![audioSession setActive:YES error:&error]) {

       NSLog(@"激活失敗:%@",[errorlocalizedDescription]);

        return;

    }

    

    [GKVoiceChatServicedefaultVoiceChatService].client=self;

   if (![[GKVoiceChatServicedefaultVoiceChatService]startVoiceChatWithParticipantID:peerIDerror:&error]) {

        NSLog(@"開啟語音失敗 :%@",[error userInfo]);

    }

}

-(void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker1{

   picker.delegate=nil;

     picker=nil;

}

-(void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state{

    

   if (state==GKPeerStateConnected) {

        isConnect=YES;

    

    }

    

   if (state==GKPeerStateDisconnected) {

        

        [[GKVoiceChatServicedefaultVoiceChatService]stopVoiceChatWithParticipantID:peerID];

       //[self disConnectAction:nil];

    }

 

}

-(void)disConnectAction:(id)sender{

    [_sessiondisconnectFromAllPeers];

    _session.available=NO;

   _session.delegate=nil;

    [_sessionsetDataReceiveHandler:nilwithContext:nil];

   _session=nil;

    isConnect=NO;

}

-(void)muteAction:(id)sender{

    [GKVoiceChatServicedefaultVoiceChatService].microphoneMuted=YES;

}

-(void)UnmuteAction:(id)sender{

    [GKVoiceChatServicedefaultVoiceChatService].microphoneMuted=NO;

}

-(NSString *)participantID{

    

   return_session.peerID;

}

 

-(void)voiceChatService:(GKVoiceChatService *)voiceChatService sendData:(NSData *)data toParticipantID:(NSString *)participantID{

   

    [_sessionsendData:datatoPeers:[NSArrayarrayWithObject:participantID]withDataMode:GKSendDataReliableerror:nil];

}

- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context

{

[[GKVoiceChatServicedefaultVoiceChatService]receivedData:datafromParticipantID:peer];

}

 

加紅的方法大家注意下。第一個加紅的方法如果不寫可能也能實現(xiàn),但會有一些內(nèi)存上的錯誤。關(guān)閉藍(lán)牙連接不是簡單的   [_session disconnectFromAllPeers];就行的  要像第二個紅色方法里那寫全才能真正正確關(guān)閉。(水平有限歡迎拍磚)。源碼至http://down.51cto.com/data/703329下載。或聯(lián)系478043385@qq.com免費索取。

網(wǎng)站欄目:IOS藍(lán)牙語音通信
URL鏈接:http://aaarwkj.com/article28/gdeccp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、用戶體驗商城網(wǎng)站、軟件開發(fā)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
一区二区三区人妻日韩| 日韩中文字幕综合不卡| 国产成人自拍视频网站| 国产区一区二区三在线播放| 亚洲国产日韩精品欧美| 国产三级全黄在线播放| 日韩 在线一区二区| 精品亚洲综合一区二区| 亚洲成人精品一区二区| 精品av一区二区在线| 国产又猛又黄又爽无遮挡| 91精品免费播放在线观看| 福利一区福利二区视频| 日本色小姐美国青青草原| 午夜夫妻生活视频在线观看 | 亚洲一区二区三区日韩精品| 日本在线一区二区视频麻豆| 国产一区二区三区自拍| 成年视频免费观看视频| 午夜激情视频在线网站| 亚洲午夜精品日韩乱码| 六十路人妻一区二区三区| 免费高清av一区二区| 国产午夜视频成人无遮挡| 热精品韩国毛久久久久久| 亚洲国产一区二区三区三州| 亚洲欧美熟妇欲乱又伦| 国产精品久久久av大片| 美女高潮久久久777| 欧美日韩国产看片一区二区| 亚洲日本国产一区二区| 麻豆精品国产粉嫩av| 人妖伪娘在线观看一区二区三区| 午夜看片国产操黑丝91网| 亚洲免费一级黄色录像片| 天堂中文字幕在线乱码一区| 一级黄片视频免费下载| 欧美日韩欧美国产精品| 国产亚洲精品福利视频| 日韩亚洲人成网站在线播放| 日本av电影一区二区三区四区|