2012年6月3日日曜日

type:video(続)

UIWebViewにvideoのエンベッド用コードを表示させた。Flash requiredなvideoはwidth、heightが埋め込まれてないので、そいつはnot availableとして対処。それ以外はクリックしたらムービーのプレーヤーが立ち上がる。

  }else if([[typeArr objectAtIndex:i]isEqualToString:@"video"]){
   NSError *error;
   NSRegularExpression *wpat=[NSRegularExpression regularExpressionWithPattern:@"width=['\"]?([0-9]+)" options:0 error:&error];
   NSRegularExpression *hpat=[NSRegularExpression regularExpressionWithPattern:@"height=['\"]?([0-9]+)" options:0 error:&error];
   int w,h;
   if(!error) {
    NSTextCheckingResult *wmatch=reg(wpat),*hmatch=reg(hpat);
    w=[[[contArr objectAtIndex:i]substringWithRange:[wmatch rangeAtIndex:1]]intValue],
    h=[[[contArr objectAtIndex:i]substringWithRange:[hmatch rangeAtIndex:1]]intValue];
   }
   if(!w||!h){
    UIImage *na=[UIImage imageNamed:@"na"];
    UIImageView *nav=[[UIImageView alloc]initWithImage:na];
    [nav setFrame:CGRectMake((sw-na.size.width)/2,(sh-na.size.height)/2,na.size.width,na.size.height)];
    [postv addSubview:nav];
   }else{
    UIWebView *video=[[UIWebView alloc]initWithFrame:CGRectMake((sw-w)/2,(sh-h)/2,w,h)];
    [video loadHTMLString:[contArr objectAtIndex:i] baseURL:nil];
    [postv addSubview:video];
   }
  }

できた。
昨日は職場の歓送迎会でラーメンは食べれず。先月末はさるぱぱ@河内永和で中華そば味付玉子ネギ。高井田系ではかなり上位の美味しさ。これで先月24杯、今年に入って96杯。やばいな。100杯いったらちょっと自粛するか。

0 件のコメント:

コメントを投稿