This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
forked from rokihiro/webrtc-handson
-
Notifications
You must be signed in to change notification settings - Fork 1
2.6.UIのセットアップ
hkato edited this page Mar 25, 2016
·
2 revisions
java
// アクションボタン
Button btnAction = (Button) findViewById(R.id.btnAction);
btnAction.setEnabled(true);
btnAction.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
v.setEnabled(false);
if (!_bEstablished){
getPeerList();
}
else{
close();
}
v.setEnabled(true);
}
});
Objective-C
略
UIButton* btnCall = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnCall setTag:TAG_WEBRTC_ACTION];
[btnCall setFrame:rcCall];
[btnCall setTitle:@"Call" forState:UIControlStateNormal];
[btnCall addTarget:self action:@selector(pushCallButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnCall];
略)
}
略)
- (void)pushCallButton:(NSObject *)sender
{
UIButton* btn = (UIButton *)sender;
if (TAG_WEBRTC_ACTION == btn.tag)
{
if (nil == _mediaConnection)
{
// Listing all peers
[self getPeerList];
}
else
{
// Closing chat
[self performSelectorInBackground:@selector(closeChat) withObject:nil];
}
}
}
Swift
//ボタンはstoryboardで設定
@IBAction func pushCallButton(sender: AnyObject) {
if self._mediaConnection == nil {
self.getPeerList()
}else{
self.performSelectorInBackground("closeChat", withObject: nil)
}
}
java
// UIを更新する
private void updateUI() {
_handler.post(new Runnable() {
@Override
public void run() {
Button btnAction = (Button) findViewById(R.id.btnAction);
if (null != btnAction) {
if (false == _bEstablished) {
btnAction.setText("Call");
} else {
btnAction.setText("Hang up");
}
}
TextView tvOwnId = (TextView) findViewById(R.id.tvOwnId);
if (null != tvOwnId) {
if (null == _id) {
tvOwnId.setText("");
} else {
tvOwnId.setText(_id);
}
}
}
});
}
Objective-C
-(void)updateUI{
dispatch_async(dispatch_get_main_queue(), ^{
//update Call Button
UIButton* btn = (UIButton *)[self.view viewWithTag:TAG_WEBRTC_ACTION];
if (NO == _bEstablished)
{
[btn setTitle:@"Call" forState:UIControlStateNormal];
}
else
{
[btn setTitle:@"Hang up" forState:UIControlStateNormal];
}
//update ID Label
UILabel* lbl = (UILabel*)[self.view viewWithTag:TAG_ID];
if (nil == _id)
{
[lbl setText:@"your ID: "];
}
else
{
[lbl setText:[NSString stringWithFormat:@"your ID: \n%@", _id]];
}
});
}
Swift
func updateUI(){
dispatch_async(dispatch_get_main_queue()) { () -> Void in
//CALLボタンのアップデート
if self._bEstablished == false{
self.callButton.titleLabel?.text = "CALL"
}else{
self.callButton.titleLabel?.text = "Hang up"
}
//IDラベルのアップデート
if self._id == nil{
self.idLabel.text = "your Id:"
}else{
self.idLabel.text = "your Id:"+self._id! as String
}
}
}
- 開発前の準備
- ビデオチャットの作成
- 2.1.サーバへ接続
- 2.2.接続成功・失敗
- 2.3.メディアの取得
- 2.4.相手から着信
- 2.5.相手へ発信
- 2.6.UIのセットアップ
- テキストチャットの作成
- 3.1.サーバへ接続
- 3.2.接続成功・失敗
- 3.3.相手から着信
- 3.4.相手へ発信
- 3.5.UIのセットアップ
- チャレンジ課題