post上传视频文件到服务端
来源:互联网 发布:nginx的优化 编辑:程序博客网 时间:2024/05/01 07:37
UIButton *videoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
videoBtn.frame = CGRectMake(20, 20, SCREENWIDTH/3, 40);
[videoBtn setImage:[UIImage imageNamed:@"录制视频.png"] forState:UIControlStateNormal];[videoBtn addTarget:self action:@selector(getVideoAction:) forControlEvents:UIControlEventTouchUpInside];[biggerKuang addSubview:videoBtn];
//添加视频模块
- (void)getVideoAction:(UIButton *)sender {
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){ UIImagePickerController* pickerView = [[UIImagePickerController alloc] init]; //UIImagePickerControllerSourceTypePhotoLibrary从手机视频调取,UIImagePickerControllerSourceTypeCamera调用摄像机 pickerView.sourceType = UIImagePickerControllerSourceTypeCamera; //UIImagePickerControllerSourceTypePhotoLibrary 从手机视频调取,UIImagePickerControllerSourceTypeCamera调用摄像机 NSArray* availableMedia = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; //availableMedia[0]是照相机 availableMedia[1]摄像机 pickerView.mediaTypes = [NSArray arrayWithObject:availableMedia[1]]; //设置前置摄像头 pickerView.cameraDevice = UIImagePickerControllerCameraDeviceFront; pickerView.videoMaximumDuration = 30; pickerView.delegate = self; [self loadpoetry]; UILabel *head = [[UILabel alloc]initWithFrame:CGRectMake(20, 44, SCREENWIDTH - 40, 50)]; head.text = @"请点击录制视频按钮,并大声朗读以下诗句"; [head setTextColor:[UIColor blueColor]]; [head setTextAlignment:NSTextAlignmentCenter]; head.numberOfLines = 0; [pickerView.view addSubview:head]; aview = [[UILabel alloc]initWithFrame:CGRectMake(10, head.bottom + 5, SCREENWIDTH - 20, 50)];
// aview.text = @”请阅读以下诗歌:锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦!”;
// aview.text = responseObject[@”message”];
[aview setTextColor:[UIColor orangeColor]];
[aview setFont:[UIFont fontWithName:@”Helvetica-Bold” size:18]];
[aview setTextAlignment:NSTextAlignmentCenter];
aview.numberOfLines = 0;
aview.backgroundColor = [UIColor clearColor];
[pickerView.view addSubview:aview];
[self presentViewController:pickerView animated:true completion:^{ }];}else{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"没有相机" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; return;}
}
(void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info
{
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];NSString *videoPath = [NSString stringWithFormat:@”%@”,[info objectForKey:UIImagePickerControllerMediaURL]];
_videoURL = [NSURL URLWithString:videoPath];
NSLog(@”123%@”,_videoURL);
//计算视频文件大小
// NSString *_fileSize = [NSString stringWithFormat:@”%ld kb”, (long)[self getFileSize:[[_videoURL absoluteString] substringFromIndex:16]]];
//计算视频总时长
// NSString *_videoLen = [NSString stringWithFormat:@”%.0f s”, [self getVideoDuration:_videoURL]];
// NSLog(@”视频大小%@,视频长度%@”,_fileSize,_videoLen);
// [self encode];
// NSLog(@”321%@”,_playUrl);//视频上传
AFHTTPRequestOperationManager *mag = [AFHTTPRequestOperationManager manager];
mag.responseSerializer = [AFHTTPResponseSerializer serializer];
// NSString *url = @”http://192.168.0.115:8081/video/save“;
NSString *url = [NSString stringWithFormat:@”%@video/save”,K_URL];
[mag POST:url parameters:@{@”userPhone”:self.zh} constructingBodyWithBlock:^(id formData) {[formData appendPartWithFileURL:_videoURL name:@"video" error:NULL];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@”成功%@”,responseObject);
NSString *str = @”success”;
flog = [NSString stringWithFormat:@”%@”,str];
NSLog(@”1111%@”,flog);
[SVProgressHUD dismiss];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@”失败%@”,error);}];
[picker dismissViewControllerAnimated:true completion:^{
}];
}
- post上传视频文件到服务端
- post请求 上传图片到服务端
- [C#]使用WebClient上传文件并同时Post表单数据字段到服务端
- 使用WebClient上传文件并同时Post表单数据字段到服务端
- android 选择视频文件 上传到后台服务器
- android 选择视频文件 上传到后台服务器
- c#上传文件到服务端
- TCP 上传图片到服务端
- 视频文件上传
- 视频文件上传
- post上传图片到服务器
- .flv视频文件上传到服务器后不能播放是怎么回事?
- uploadify 上传,传递参数到服务端
- actionscript里面如何上传文件到服务端?
- android端上传图片到服务端
- 服务端签名后上传文件到oss
- asp.net 从静态页Post发送数据到服务端
- Android使用HttpURLConnection发送Post请求到服务端
- PS中预设画笔并为路径描边
- Asp程序做页面的301跳转,使得cnasda.com跳转到www.cnasda.com
- iOS AutoLayout代码版
- PHP获取优酷视频FLV地址
- JS 去除字符串中的最后一个字符
- post上传视频文件到服务端
- JQ插件的写法及使用整理
- JS 中 indexOf 的用户及注意事项
- IncrediBuild工具使用及设置
- 如何使自己的网站与UC进行用户整合
- PHP 获取页面地址参数详解整理
- 调用可能未定义的方法 attachVideo (通过 static 类型 flash.media:Video 引用)解决办法
- Win8离线安装.net framework组件
- 给指定控件切割任意角为圆角