BGTCUploadHelp.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // BGTCUploadHelp.m
  3. // BuguLive
  4. //
  5. // Created by 志刚杨 on 2020/9/3.
  6. // Copyright © 2020 xfg. All rights reserved.
  7. //
  8. #import "BGTCUploadHelp.h"
  9. #import "TXUGCPublish.h"
  10. @interface BGTCUploadHelp()<TXVideoPublishListener>
  11. @property(nonatomic, strong) TXUGCPublish *ugcPublish;
  12. @property(nonatomic, strong) NSString *signature;
  13. @property(nonatomic, strong) NSString *videoPath;
  14. @end
  15. @implementation BGTCUploadHelp
  16. {
  17. }
  18. BogoSingletonM(BGTCUploadHelp);
  19. -(void)uploadVideoWithVideoPath:(NSString *)videoPath
  20. {
  21. _videoPath = videoPath;
  22. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  23. [dict setValue:@"app" forKey:@"ctl"];
  24. [dict setValue:@"app_request_get_upload_sign" forKey:@"act"];
  25. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  26. if ([responseJson toInt:@"status"] == 1) {
  27. _signature = [responseJson toString:@"signature"];
  28. TXPublishParam * param = [[TXPublishParam alloc] init];
  29. param.signature = _signature;
  30. param.videoPath = _videoPath;
  31. _ugcPublish = [[TXUGCPublish alloc] init];
  32. _ugcPublish.delegate = self;
  33. [_ugcPublish publishVideo:param];
  34. }else{
  35. }
  36. } FailureBlock:^(NSError *error) {
  37. }];
  38. }
  39. -(void) onPublishProgress:(uint64_t)uploadBytes totalBytes: (uint64_t)totalBytes;
  40. {
  41. NSLog(ASLocalizedString(@"腾讯云视频进度 %llu"),totalBytes);
  42. }
  43. -(void) onPublishComplete:(TXPublishResult*)result;
  44. {
  45. if (!result.retCode) {
  46. self.publishResult(YES,result.videoURL,ASLocalizedString(@"上传成功"));
  47. } else {
  48. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"TCVideoPublish.PublishingFailedFmt", nil), result.retCode];
  49. self.publishResult(NO,@"",msg);
  50. return;
  51. }
  52. }
  53. @end