TCVideoPublishController.m 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. #import "TCVideoPublishController.h"
  2. #import "UIView+CustomAutoLayout.h"
  3. #import "TCVideoRecordViewController.h"
  4. #import <TXLiteAVSDK_Professional/TXUGCRecord.h>
  5. #import <TXLiteAVSDK_Professional/TXLivePlayer.h>
  6. #import <AssetsLibrary/AssetsLibrary.h>
  7. #import <AVFoundation/AVFoundation.h>
  8. #import "PublishShareV.h"
  9. #import "YBTabBarController.h"
  10. #import "AFNetworking.h"
  11. #import <TXLiteAVSDK_Professional/TXVideoEditer.h>
  12. #import "videoTopicVC.h"
  13. #import "YBVideoAddGoodsVC.h"
  14. #import "YBVideoClassVC.h"
  15. #import "YBSetChargeView.h"
  16. #import "YBTakeSameVideoVC.h"
  17. #import "YBStorageObj.h"
  18. #import "YBShareView.h"
  19. #import "TCVideoRecordViewController.h"
  20. #import "TCVideoEditViewController.h"
  21. #import "YBGoodsListVC.h"
  22. #import "YBPublishCoverVC.h"
  23. #import "RelationVideoGoodsVC.h"
  24. @interface TCVideoPublishController()<TXLivePlayListener>
  25. @property (nonatomic,strong) NSString *imagekey;
  26. @property (nonatomic,strong) NSString *videokey;
  27. //分享的视频id 和 截图
  28. @property (nonatomic,strong) NSString *videoid;
  29. @property (nonatomic,strong) NSString *image_thumb;
  30. /** 背景scorll */
  31. @property(nonatomic,strong)UIScrollView *bgScrollView;
  32. /** 顶部组合:视频预览、视频描述 */
  33. @property(nonatomic,strong)UIView *topMix;
  34. @property(nonatomic,strong)UIView *videoPreview; //视频预览
  35. @property(nonatomic,strong)UIImageView *videoCoverIV; //视频封面
  36. @property(nonatomic,assign)int coverSelIndex;
  37. @property(nonatomic,strong)MyTextView *videoDesTV; //视频描述
  38. @property(nonatomic,strong) UILabel *wordsNumL; //字符统计
  39. @property(nonatomic,strong) UIButton *isAdBtn; //广告按钮
  40. /** 定位组合:图标、位置 */
  41. @property(nonatomic,strong)UIView *locationV;
  42. /** 分享平台组合 */
  43. @property(nonatomic,strong)PublishShareV *platformV;
  44. /** 发布按钮 */
  45. @property(nonatomic,strong)UIButton *publishBtn;
  46. // 活动
  47. @property(nonatomic,strong)UIView *activeView;
  48. @property(nonatomic,strong)UILabel *activeTagL;
  49. //话题
  50. @property(nonatomic,strong)UIView *topicView;
  51. @property (nonatomic,strong) UILabel *topicLabel;
  52. @property (nonatomic,strong) NSDictionary *topicDic;
  53. //商品
  54. @property(nonatomic,strong)UIView *shopView;
  55. @property (nonatomic,strong) UILabel *shopLabel;
  56. @property (nonatomic,strong) NSMutableDictionary *shopDic;
  57. @property(nonatomic,strong)NSString *shopJsonStr; //废弃--改为goodsID
  58. @property(nonatomic,strong)NSString *goodsID;
  59. //@property (nonatomic,strong) UIImage *goodsThumb;
  60. //广告
  61. @property(nonatomic,strong)UIView *adView;
  62. @property(nonatomic,strong)UITextField *adTextView;
  63. //分类
  64. @property(nonatomic,strong)UIView *videoClassView;
  65. @property(nonatomic,strong)UILabel *videoClassL;
  66. @property(nonatomic,strong)NSDictionary *videoClassDic;
  67. //收费
  68. @property(nonatomic,strong)UIView *videoChargeView;
  69. @property(nonatomic,strong)UILabel *videoChargeL;
  70. @property(nonatomic,strong)NSString *videoChargeNum;
  71. @end
  72. @implementation TCVideoPublishController {
  73. NSString *sharetype; //分享类型
  74. NSString *mytitle;
  75. TXLivePlayer *_livePlayer;
  76. TXUGCRecordResult *_recordResult;
  77. BOOL _isPublished;
  78. BOOL _playEnable;
  79. NSString *_cosImgFinshPath;
  80. NSString *_cosVideoFinshPath;
  81. NSString *_cosWaterVFinshPath;
  82. BOOL _shareBack;
  83. CGFloat _allOrV;
  84. CGFloat _allOrC;
  85. CGFloat _allWaV;
  86. int _allNum;
  87. }
  88. - (instancetype)initWithPath:(NSString *)videoPath videoMsg:(TXVideoInfo *) videoMsg {
  89. TXUGCRecordResult *recordResult = [TXUGCRecordResult new];
  90. //recordResult.coverImage = videoMsg.coverImage;
  91. recordResult.coverImage = [TXVideoInfoReader getSampleImage:0.0 videoPath:videoPath];
  92. recordResult.videoPath = videoPath;
  93. return [self init:nil recordType:0 RecordResult:recordResult TCLiveInfo:nil];
  94. }
  95. - (instancetype)init:(id)videoRecorder recordType:(NSInteger)recordType RecordResult:(TXUGCRecordResult *)recordResult TCLiveInfo:(NSDictionary *)liveInfo {
  96. self = [super init];
  97. if (self) {
  98. sharetype = @"qx";
  99. _recordResult = recordResult;
  100. _isPublished = NO;
  101. _playEnable = YES;
  102. _coverSelIndex = 0;
  103. /*rk_200916
  104. _livePlayer = [[TXLivePlayer alloc] init];
  105. _livePlayer.delegate = self;
  106. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
  107. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
  108. */
  109. }
  110. return self;
  111. }
  112. - (void)viewWillAppear:(BOOL)animated{
  113. [super viewWillAppear:animated];
  114. }
  115. -(void)viewDidAppear:(BOOL)animated {
  116. [super viewDidAppear:animated];
  117. /*rk_200916
  118. _playEnable = YES;
  119. if (_isPublished == NO) {
  120. [_livePlayer startPlay:_recordResult.videoPath type:PLAY_TYPE_LOCAL_VIDEO];
  121. }
  122. */
  123. }
  124. - (void)viewDidDisappear:(BOOL)animated {
  125. [super viewDidDisappear:animated];
  126. [UIApplication sharedApplication].statusBarHidden = NO;
  127. /*rk_200916
  128. _playEnable = NO;
  129. [_livePlayer stopPlay];
  130. */
  131. }
  132. - (void)viewDidLoad {
  133. [super viewDidLoad];
  134. self.navigationController.interactivePopGestureRecognizer.enabled = NO;
  135. self.navigationController.interactivePopGestureRecognizer.delegate =nil;
  136. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(endBackground) name:UIApplicationWillEnterForegroundNotification object:nil];
  137. [UIApplication sharedApplication].statusBarHidden = NO;
  138. self.navigationController.navigationBarHidden = YES;
  139. self.view.backgroundColor = Normal_Color;
  140. self.titleL.text = YZMsg(@"发布视频");
  141. _cosImgFinshPath = @"";
  142. _cosVideoFinshPath = @"";
  143. _cosWaterVFinshPath = @"";
  144. _shopDic = @{}.mutableCopy;
  145. _shopJsonStr = @"";
  146. _goodsID = @"0";
  147. UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyboard:)];
  148. singleTap.cancelsTouchesInView = NO;
  149. [self.view addGestureRecognizer:singleTap];
  150. [self.view addSubview:self.bgScrollView];
  151. _bgScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  152. /*rk_200916
  153. [_livePlayer setupVideoWidget:CGRectZero containView:_videoPreview insertIndex:0];
  154. */
  155. [BGSetting getBgSettingUpdate:NO maintain:NO eventBack:nil];
  156. }
  157. -(void)endBackground{
  158. if (_shareBack) {
  159. [self root];
  160. }
  161. }
  162. //- (void)dealloc {
  163. // [[NSNotificationCenter defaultCenter]removeObserver:self];
  164. //}
  165. - (void)closeKeyboard:(UITapGestureRecognizer *)gestureRecognizer {
  166. [_videoDesTV resignFirstResponder];
  167. [_adTextView resignFirstResponder];
  168. }
  169. #pragma mark - 发布
  170. - (void)clickPublishBtn {
  171. //写暂停
  172. [_livePlayer pause];
  173. //测试
  174. /*
  175. [self root];
  176. return;
  177. */
  178. NSString *is_userad;
  179. NSString *userad_url;
  180. if (_isAdBtn.isSelected == YES) {
  181. is_userad = @"1";
  182. userad_url = _adTextView.text;
  183. _goodsID = @"0";
  184. }else{
  185. is_userad = @"0";
  186. userad_url = @"";
  187. }
  188. _publishBtn.enabled = NO;
  189. [self.view endEditing:YES];
  190. mytitle = [NSString stringWithFormat:@"%@",_videoDesTV.text];//标题
  191. //上传
  192. AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
  193. app.videoTitle = mytitle;
  194. app.originalCover = _videoCoverIV.image ? _videoCoverIV.image : _recordResult.coverImage;
  195. app.originalVdieoPath = _recordResult.videoPath;
  196. app.originalMKVideoPath = _waterVideoPath;
  197. app.is_userad = is_userad;
  198. app.userad_url = userad_url;
  199. app.topicID = _topicDic ? minstr([_topicDic valueForKey:@"id"]):@"0";
  200. app.videoClassID = [PublicObj checkNull:minstr([_videoClassDic valueForKey:@"id"])]?@"0":minstr([_videoClassDic valueForKey:@"id"]);
  201. app.musicID = _musicID;
  202. //app.shopJsonStr = [PublicObj checkNull:_shopJsonStr]?@"":_shopJsonStr;
  203. app.goodsID = _goodsID;
  204. app.videoChargeNum = [PublicObj checkNull:_videoChargeNum]?@"0":_videoChargeNum;
  205. // 活动
  206. app.activeId = [YBActiveManager shareManager].activeId ? [YBActiveManager shareManager].activeId:@"";
  207. [app startUpload];
  208. [self root];
  209. /*
  210. YBWeakSelf;
  211. [[YBStorageObj storageManeger]getCOSType:^(int code) {
  212. if (code == 0) {
  213. [weakSelf startUpload];
  214. }
  215. }];
  216. */
  217. }
  218. /*
  219. -(void)startUpload {
  220. _isPublished = YES;
  221. [MBProgressHUD showMessage:YZMsg(@"发布中")];
  222. dispatch_group_t group = dispatch_group_create();
  223. dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
  224. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  225. YBWeakSelf;
  226. _allOrV = 0.0;
  227. _allOrC = 0.0;
  228. _allWaV = 0.0;
  229. _allNum = 2;
  230. //原始图片
  231. dispatch_group_async(group, queue, ^{
  232. UIImage *saveImg = _recordResult.coverImage;
  233. if (!_recordResult.coverImage) {
  234. saveImg = [TXVideoInfoReader getSampleImage:0.0 videoPath:_recordResult.videoPath];
  235. }
  236. NSString *imageName = [PublicObj getNameBaseCurrentTime:@"_origin.png"];
  237. [[YBStorageObj storageManeger]yb_storageImg:saveImg andName:imageName progress:^(CGFloat percent) {
  238. //NSLog(@"%@--<>:%f",imageName,percent);
  239. _allOrC = percent;
  240. [weakSelf ybUploadProgress];
  241. } complete:^(int code, NSString *key) {
  242. _cosImgFinshPath = minstr(key);
  243. dispatch_semaphore_signal(semaphore);
  244. }];
  245. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  246. });
  247. //原始视频
  248. dispatch_group_async(group, queue, ^{
  249. NSString *videoName = [PublicObj getNameBaseCurrentTime:@"_origin.mp4"];
  250. NSString *videoPath = _recordResult.videoPath;
  251. [[YBStorageObj storageManeger]yb_storageVideoOrVoice:videoPath andName:videoName progress:^(CGFloat percent) {
  252. //NSLog(@"%@--<>:%f",videoName,percent);
  253. _allOrV = percent;
  254. [weakSelf ybUploadProgress];
  255. } complete:^(int code, NSString *key) {
  256. _cosVideoFinshPath = minstr(key);
  257. dispatch_semaphore_signal(semaphore);
  258. }];
  259. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  260. });
  261. //水印视频
  262. if (_waterVideoPath) {
  263. _allNum = 3;
  264. dispatch_group_async(group, queue, ^{
  265. NSString *videoName = [PublicObj getNameBaseCurrentTime:@"_water.mp4"];
  266. [[YBStorageObj storageManeger]yb_storageVideoOrVoice:_waterVideoPath andName:videoName progress:^(CGFloat percent) {
  267. //NSLog(@"shui%@--<>:%f",videoName,percent);
  268. _allWaV = percent;
  269. [weakSelf ybUploadProgress];
  270. } complete:^(int code, NSString *key) {
  271. _cosWaterVFinshPath = minstr(key);
  272. dispatch_semaphore_signal(semaphore);
  273. }];
  274. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  275. });
  276. }
  277. dispatch_group_notify(group, queue, ^{
  278. dispatch_async(dispatch_get_main_queue(), ^{
  279. [weakSelf requstAPPServceTitle:mytitle andVideo:_cosVideoFinshPath andImage:_cosImgFinshPath andWaterName:_cosWaterVFinshPath];
  280. });
  281. NSLog(@"任务完成执行");
  282. });
  283. }
  284. -(void)ybUploadProgress{
  285. NSLog(@"allll:%f",(_allOrC+_allOrV+_allWaV)/_allNum);
  286. }
  287. */
  288. #pragma mark - UITextViewDelegate
  289. - (void)textViewDidChange:(UITextView*)textView {
  290. NSString *toBeString = textView.text;
  291. NSString *lang = [[[UITextInputMode activeInputModes]firstObject] primaryLanguage];
  292. if ([lang isEqualToString:@"zh-Hans"]) {
  293. UITextRange *selectedRange = [textView markedTextRange];
  294. UITextPosition *position = [textView positionFromPosition:selectedRange.start offset:0];
  295. if (!position) {
  296. if (toBeString.length > 50) {
  297. textView.text = [toBeString substringToIndex:50];
  298. _wordsNumL.text = [NSString stringWithFormat:@"%lu/50",(textView.text.length)];
  299. }else{
  300. _wordsNumL.text = [NSString stringWithFormat:@"%lu/50",(toBeString.length)];
  301. }
  302. }else{
  303. //有高亮选择的字符串,则暂不对文字进行统计和限制
  304. }
  305. }else{
  306. // 中文输入法以外的直接对其统计限制即可,不考虑其他语种情况
  307. if (toBeString.length > 50) {
  308. textView.text = [toBeString substringToIndex:50];
  309. _wordsNumL.text = [NSString stringWithFormat:@"%lu/50",(textView.text.length)];
  310. }else{
  311. _wordsNumL.text = [NSString stringWithFormat:@"%lu/50",(toBeString.length)];
  312. }
  313. }
  314. }
  315. /*rk_200916
  316. - (void)applicationWillEnterForeground:(NSNotification *)noti {
  317. //temporary fix bug
  318. if ([self.navigationItem.title isEqualToString:YZMsg(@"发布中")])
  319. return;
  320. if (_isPublished == NO) {
  321. [_livePlayer startPlay:_recordResult.videoPath type:PLAY_TYPE_LOCAL_VIDEO];
  322. }
  323. }
  324. - (void)applicationDidEnterBackground:(NSNotification *)noti {
  325. [_livePlayer stopPlay];
  326. }
  327. #pragma mark TXLivePlayListener
  328. -(void) onPlayEvent:(int)EvtID withParam:(NSDictionary*)param {
  329. dispatch_async(dispatch_get_main_queue(), ^{
  330. if (EvtID == PLAY_EVT_PLAY_END && _playEnable) {
  331. [_livePlayer startPlay:_recordResult.videoPath type:PLAY_TYPE_LOCAL_VIDEO];
  332. return;
  333. }
  334. });
  335. }
  336. -(void) onNetStatus:(NSDictionary*) param {
  337. return;
  338. }
  339. */
  340. #pragma mark -
  341. #pragma mark - 上传七牛或者腾讯云存储成功后把视频地址、封面地址反馈给自己的服务器
  342. -(void)requstAPPServceTitle:(NSString *)myTile andVideo:(NSString *)video andImage:(NSString *)image andWaterName:(NSString *)water {
  343. _publishBtn.enabled = YES;
  344. _isPublished = NO;
  345. if ([PublicObj checkNull:_cosVideoFinshPath] || [PublicObj checkNull:_cosImgFinshPath] || (![PublicObj checkNull:_waterVideoPath] && [PublicObj checkNull:_cosWaterVFinshPath])) {
  346. [MBProgressHUD hideHUD];
  347. [MBProgressHUD showPop:YZMsg(@"发布失败")];
  348. return;
  349. }
  350. //写暂停
  351. [_livePlayer pause];
  352. __weak TCVideoPublishController *weakself = self;
  353. NSString *videoClassID = [PublicObj checkNull:minstr([_videoClassDic valueForKey:@"id"])]?@"0":minstr([_videoClassDic valueForKey:@"id"]);
  354. NSMutableDictionary *pullDic = @{
  355. @"uid":[Config getOwnID],
  356. @"token":[Config getOwnToken],
  357. @"title":minstr(myTile),
  358. @"href":minstr(video),
  359. @"thumb":minstr(image),
  360. @"lng":[NSString stringWithFormat:@"%@",[cityDefault getLocationLng]],
  361. @"lat":[NSString stringWithFormat:@"%@",[cityDefault getLocationLat]],
  362. @"city":[NSString stringWithFormat:@"%@",[cityDefault getLocationCity]?[cityDefault getLocationCity]:YZMsg(@"好像在火星")],
  363. @"music_id":_musicID ? _musicID : @"0",
  364. @"labelid":_topicDic ? minstr([_topicDic valueForKey:@"id"]):@"0",
  365. //@"goodsinfo": [PublicObj checkNull:_shopJsonStr]?@"":_shopJsonStr,
  366. @"goodsid":_goodsID,
  367. @"href_w":water?water:@"",
  368. @"classid":videoClassID,
  369. @"coin":[PublicObj checkNull:_videoChargeNum]?@"0":_videoChargeNum,
  370. }.mutableCopy;
  371. [YBNetworking postWithUrl:@"Video.setVideo" Dic:pullDic Suc:^(int code, id info, NSString *msg) {
  372. if (code == 0) {
  373. [MBProgressHUD hideHUD];
  374. NSString *audit_switch = [NSString stringWithFormat:@"%@",[common getAuditSwitch]];
  375. if ([audit_switch isEqual:@"1"]) {
  376. [MBProgressHUD showSuccess:YZMsg(@"上传成功,请等待审核")];
  377. }else{
  378. [MBProgressHUD showSuccess:YZMsg(@"发布成功")];
  379. }
  380. BOOL isOk = [[NSFileManager defaultManager] removeItemAtPath:_recordResult.videoPath error:nil];
  381. if (_waterVideoPath) {
  382. [[NSFileManager defaultManager] removeItemAtPath:_waterVideoPath error:nil];
  383. }
  384. NSLog(@"%d shanchushanchushanchu",isOk);
  385. NSDictionary *infoDic = [info firstObject];
  386. _videoid = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"id"]];
  387. _image_thumb = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"thumb_s"]];
  388. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  389. [weakself pushshare];
  390. //发布成功后刷新首页
  391. //[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadlist" object:nil];
  392. weakself.publishBtn.enabled = NO;
  393. });
  394. }else {
  395. [MBProgressHUD hideHUD];
  396. [MBProgressHUD showError:msg];
  397. weakself.publishBtn.enabled = YES;
  398. }
  399. } Fail:^(id fail) {
  400. [MBProgressHUD hideHUD];
  401. [MBProgressHUD showError:YZMsg(@"网络连接断开,视频上传失败")];
  402. weakself.publishBtn.enabled = YES;
  403. }];
  404. }
  405. #pragma mark - 分享
  406. -(void)root {
  407. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  408. //[self.navigationController popToRootViewControllerAnimated:YES];
  409. if (_livePlayer) {
  410. [_livePlayer stopPlay];
  411. _livePlayer = nil;
  412. }
  413. for (UIViewController *vc in self.navigationController.childViewControllers) {
  414. if ([vc isKindOfClass:[TCVideoRecordViewController class]]||[vc isKindOfClass:[TCVideoEditViewController class]]) {
  415. [vc.view removeFromSuperview];
  416. [vc removeFromParentViewController];
  417. NSLog(@"rk20200118===释放VC:%@",vc);
  418. }
  419. }
  420. if (_isTakeSame == YES) {
  421. //拍同款返回到同款音乐视频列表
  422. BOOL findVC = NO;
  423. for (UIViewController *forVC in self.navigationController.childViewControllers) {
  424. if ([forVC isKindOfClass:[YBTakeSameVideoVC class]]) {
  425. findVC = YES;
  426. [self.navigationController popToViewController:forVC animated:YES];
  427. break;
  428. }
  429. }
  430. if (findVC == NO) {
  431. [self goHomePageView];
  432. }
  433. }
  434. else if (![PublicObj checkNull:[YBActiveManager shareManager].activeId]){
  435. if ([YBActiveManager shareManager].startVC) {
  436. YBBaseViewController *gobackVC = [YBActiveManager shareManager].startVC;
  437. [self.navigationController popToViewController:gobackVC animated:YES];
  438. [[YBActiveManager shareManager] resetActive];
  439. }else {
  440. [self goHomePageView];
  441. }
  442. }else {
  443. [self goHomePageView];
  444. }
  445. // NSLog(@"1031==vc1==%lu=====%@",self.navigationController.childViewControllers.count,self.navigationController.childViewControllers);
  446. // for (UIViewController *vc in self.navigationController.childViewControllers) {
  447. // [vc.view removeFromSuperview];
  448. // [vc removeFromParentViewController];
  449. // }
  450. // NSLog(@"1031==vc2==%lu=====%@",self.navigationController.childViewControllers.count,self.navigationController.childViewControllers);
  451. // [PublicObj resetVC:[[YBTabBarController alloc]initWithAlert:NO]];
  452. });
  453. }
  454. -(void)goHomePageView {
  455. [self.navigationController popToRootViewControllerAnimated:YES];
  456. YBTabBarController *tabbar = [PublicObj currentTabbar];
  457. [tabbar selectController:0];
  458. [tabbar goForYouViewRefresh:NO];
  459. [[NSNotificationCenter defaultCenter]postNotificationName:@"changTabBarColor" object:@"0"];
  460. }
  461. -(void)pushshare {
  462. if ([sharetype isEqual:@"qx"]) {
  463. [self root];
  464. return;
  465. }
  466. _shareBack = YES;
  467. YBWeakSelf;
  468. /*
  469. NSString *titles = _videoDesTV.text;
  470. if (_videoDesTV.text.length == 0) {
  471. titles = [NSString stringWithFormat:@"%@%@",[Config getOwnNicename],[common video_share_des]];
  472. }
  473. */
  474. NSString *shareDes = [common video_share_des];
  475. if (![PublicObj checkNull:_videoDesTV.text]) {
  476. shareDes = _videoDesTV.text;
  477. }
  478. NSDictionary *shareDic = @{@"id":_videoid,@"thumb_s":_image_thumb,@"publish_des":shareDes};
  479. [[YBShareView noShareUIManager]executeShareWithType:RKShareType_VideoPublish shareType:sharetype parameter:shareDic complete:^(int codeEvent, NSString *nums) {
  480. [weakSelf root];
  481. }];
  482. }
  483. #pragma mark - set/get
  484. - (UIScrollView *)bgScrollView {
  485. if (!_bgScrollView) {
  486. _bgScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight)];
  487. _bgScrollView.contentInset = UIEdgeInsetsMake(0, 0, ShowDiff, 0);
  488. _bgScrollView.bounces = NO;
  489. //顶部视图:预览、描述
  490. [_bgScrollView addSubview:self.topMix];
  491. //定位
  492. [_bgScrollView addSubview:self.locationV];
  493. // 活动
  494. if (![PublicObj checkNull:[YBActiveManager shareManager].activeId]) {
  495. [_bgScrollView addSubview:self.activeView];
  496. }
  497. //话题
  498. [_bgScrollView addSubview:self.topicView];
  499. //分类
  500. [_bgScrollView addSubview:self.videoClassView];
  501. //价格
  502. NSString *canSetP = minstr([YBPower getVideoCharge]);
  503. if ([canSetP isEqual:@"1"]) {
  504. [_bgScrollView addSubview:self.videoChargeView];
  505. }
  506. //广告链接
  507. NSString *isad = minstr([YBPower getIsad]);
  508. if ([isad isEqual:@"1"]) {
  509. [_bgScrollView addSubview:self.adView];
  510. self.adView.hidden = YES;
  511. }
  512. //商品
  513. NSString *isShop = minstr([YBPower getIsShop]);
  514. if ([isShop isEqual:@"1"]) {
  515. [_bgScrollView addSubview:self.shopView];
  516. }
  517. /*
  518. //分享平台
  519. [_bgScrollView addSubview:self.platformV];
  520. if ([common share_type].count==0) {
  521. self.platformV.hidden = YES;
  522. }
  523. */
  524. //发布
  525. [_bgScrollView addSubview:self.publishBtn];
  526. [_bgScrollView layoutIfNeeded];
  527. CGFloat maxY = CGRectGetMaxY(_publishBtn.frame)+10;
  528. if (maxY < _window_height-64-statusbarHeight-ShowDiff) {
  529. maxY = _window_height-64-statusbarHeight-ShowDiff;
  530. }
  531. _bgScrollView.contentSize = CGSizeMake(0, maxY);
  532. }
  533. return _bgScrollView;
  534. }
  535. -(UIView *)topMix {
  536. if (!_topMix) {
  537. _topMix = [[UIView alloc] initWithFrame:CGRectMake(15, 10, _window_width-30, 180)];
  538. _topMix.backgroundColor = RGB_COLOR(@"#15102C", 1);
  539. //视频预览-封面
  540. _videoPreview = [[UIView alloc] initWithFrame:CGRectMake(15, 15, 100, 150)];
  541. _videoPreview.layer.cornerRadius = 3;
  542. _videoPreview.layer.masksToBounds = YES;
  543. _videoCoverIV = [[UIImageView alloc]init];
  544. _videoCoverIV.image = _recordResult.coverImage;
  545. _videoCoverIV.contentMode = UIViewContentModeScaleAspectFill;
  546. _videoCoverIV.clipsToBounds = YES;
  547. [_videoPreview addSubview:_videoCoverIV];
  548. [_videoCoverIV mas_makeConstraints:^(MASConstraintMaker *make) {
  549. make.width.height.centerX.centerY.equalTo(_videoPreview);
  550. }];
  551. UIButton *coverBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  552. coverBtn.backgroundColor = RGB_COLOR(@"#000000", 0.5);
  553. coverBtn.titleLabel.font = SYS_Font(13);
  554. [coverBtn setTitle:YZMsg(@"添加封面") forState:0];
  555. [coverBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  556. coverBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 0, 3, 0);
  557. [coverBtn addTarget:self action:@selector(clickCovderBtn) forControlEvents:UIControlEventTouchUpInside];
  558. [_videoPreview addSubview:coverBtn];
  559. [coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  560. make.width.centerX.bottom.equalTo(_videoPreview);
  561. }];
  562. //视频描述
  563. _videoDesTV = [[MyTextView alloc] initWithFrame:CGRectMake(_videoPreview.right+10, 15, _topMix.width-_videoPreview.width - 35, _videoPreview.height)];
  564. _videoDesTV.backgroundColor = [UIColor clearColor];
  565. _videoDesTV.delegate = self;
  566. _videoDesTV.layer.borderColor = _topMix.backgroundColor.CGColor;
  567. _videoDesTV.font = SYS_Font(16);
  568. _videoDesTV.textColor = RGB_COLOR(@"#969696", 1);
  569. _videoDesTV.placeholder = YZMsg(@"添加视频描述~");
  570. _videoDesTV.placeholderColor = RGB_COLOR(@"#969696", 1);
  571. _wordsNumL = [[UILabel alloc] initWithFrame:CGRectMake(_videoDesTV.right-50, _videoDesTV.bottom-12, 50, 12)];
  572. _wordsNumL.text = @"0/50";
  573. _wordsNumL.textColor = RGB_COLOR(@"#969696", 1);
  574. _wordsNumL.font = [UIFont systemFontOfSize:12];
  575. _wordsNumL.backgroundColor =[UIColor clearColor];
  576. _wordsNumL.textAlignment = NSTextAlignmentRight;
  577. _isAdBtn = [UIButton buttonWithType:0];
  578. _isAdBtn.frame = CGRectMake(_videoPreview.right+10, _videoDesTV.bottom-20, 45, 19);
  579. [_isAdBtn setImage:[UIImage imageNamed:getImagename(@"ad_关闭")] forState:UIControlStateNormal];
  580. [_isAdBtn setImage:[UIImage imageNamed:getImagename(@"ad_开启")] forState:UIControlStateSelected];
  581. [_isAdBtn addTarget:self action:@selector(isadBtnClick) forControlEvents:UIControlEventTouchUpInside];
  582. if ([[YBPower getIsad] isEqual:@"1"]) {
  583. _isAdBtn.hidden = NO;
  584. }else{
  585. _isAdBtn.hidden = YES;
  586. }
  587. [_topMix addSubview:_videoPreview];
  588. [_topMix addSubview:_videoDesTV];
  589. [_topMix addSubview:_wordsNumL];
  590. [_topMix addSubview:_isAdBtn];
  591. }
  592. return _topMix;
  593. }
  594. -(UIView *)locationV {
  595. if (!_locationV) {
  596. //显示定位
  597. _locationV = [[UIView alloc]initWithFrame:CGRectMake(15, _topMix.bottom+5, _window_width-30, 50)];
  598. _locationV.backgroundColor = RGB_COLOR(@"#15102C", 1);
  599. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pink_location"]];
  600. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  601. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  602. [_locationV addSubview:imageloca];
  603. UILabel *locationlabels = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _window_width-50, 50)];
  604. locationlabels.font = SYS_Font(15);
  605. locationlabels.text = [NSString stringWithFormat:@"%@",[cityDefault getLocationCity]?[cityDefault getLocationCity]:YZMsg(@"好像在火星")];
  606. locationlabels.textColor = RGB_COLOR(@"#666666", 1);
  607. [_locationV addSubview:locationlabels];
  608. }
  609. return _locationV;
  610. }
  611. // 活动
  612. - (UIView *)activeView {
  613. if (!_activeView) {
  614. _activeView = [[UIView alloc]initWithFrame:CGRectMake(15, _locationV.bottom+5, _window_width-30, 50)];
  615. _activeView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  616. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"video_active"]];
  617. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  618. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  619. [_activeView addSubview:imageloca];
  620. _activeTagL = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _window_width-60, 50)];
  621. _activeTagL.font = SYS_Font(15);
  622. _activeTagL.text = [YBActiveManager shareManager].activeTag;
  623. _activeTagL.textColor = RGB_COLOR(@"#666666", 1);
  624. [_activeView addSubview:_activeTagL];
  625. }
  626. return _activeView;
  627. }
  628. -(UIView *)topicView {
  629. if (!_topicView) {
  630. //话题
  631. UIView *lastView = _locationV;
  632. if (![PublicObj checkNull:[YBActiveManager shareManager].activeId]) {
  633. lastView = _activeView;
  634. }
  635. _topicView = [[UIView alloc]initWithFrame:CGRectMake(15, lastView.bottom+5, _window_width-30, 50)];
  636. _topicView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  637. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"video_topic"]];
  638. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  639. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  640. [_topicView addSubview:imageloca];
  641. _topicLabel = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _window_width-50, 50)];
  642. _topicLabel.font = SYS_Font(15);
  643. _topicLabel.text = YZMsg(@"话题标签");
  644. _topicLabel.textColor = RGB_COLOR(@"#666666", 1);
  645. [_topicView addSubview:_topicLabel];
  646. UIImageView *rightImgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"askWhite_jiantou"]];
  647. rightImgV.contentMode = UIViewContentModeScaleAspectFit;
  648. rightImgV.frame = CGRectMake(_locationV.width-20,_locationV.height/2-7.5,15,15);
  649. [_topicView addSubview:rightImgV];
  650. UIButton *btn = [UIButton buttonWithType:0];
  651. btn.frame = CGRectMake(0, 0, _topicView.width, _topicView.height);
  652. [btn addTarget:self action:@selector(addTopicClick) forControlEvents:UIControlEventTouchUpInside];
  653. [_topicView addSubview:btn];
  654. }
  655. return _topicView;
  656. }
  657. - (UIView *)videoClassView {
  658. if (!_videoClassView) {
  659. _videoClassView = [[UIView alloc]initWithFrame:CGRectMake(15, _topicView.bottom+5, _window_width-30, 50)];
  660. _videoClassView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  661. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"视频-分类"]];
  662. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  663. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  664. [_videoClassView addSubview:imageloca];
  665. _videoClassL = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _window_width-50, 50)];
  666. _videoClassL.font = SYS_Font(15);
  667. _videoClassL.text = YZMsg(@"视频分类");
  668. _videoClassL.textColor = RGB_COLOR(@"#666666", 1);
  669. [_videoClassView addSubview:_videoClassL];
  670. UIImageView *rightImgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"askWhite_jiantou"]];
  671. rightImgV.contentMode = UIViewContentModeScaleAspectFit;
  672. rightImgV.frame = CGRectMake(_locationV.width-20,_locationV.height/2-7.5,15,15);
  673. [_videoClassView addSubview:rightImgV];
  674. UIButton *btn = [UIButton buttonWithType:0];
  675. btn.frame = CGRectMake(0, 0, _videoClassView.width, _videoClassView.height);
  676. [btn addTarget:self action:@selector(clikcVideoClassBtn) forControlEvents:UIControlEventTouchUpInside];
  677. [_videoClassView addSubview:btn];
  678. }
  679. return _videoClassView;
  680. }
  681. - (UIView *)videoChargeView {
  682. if (!_videoChargeView) {
  683. _videoChargeView = [[UIView alloc]initWithFrame:CGRectMake(15, _videoClassView.bottom+5, _window_width-30, 50)];
  684. _videoChargeView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  685. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"视频-收费"]];
  686. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  687. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  688. [_videoChargeView addSubview:imageloca];
  689. _videoChargeL = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _window_width-50, 50)];
  690. _videoChargeL.font = SYS_Font(15);
  691. _videoChargeL.text = YZMsg(@"设置收费");
  692. _videoChargeL.textColor = RGB_COLOR(@"#666666", 1);
  693. [_videoChargeView addSubview:_videoChargeL];
  694. _videoChargeNum = @"0";
  695. UIImageView *rightImgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"askWhite_jiantou"]];
  696. rightImgV.contentMode = UIViewContentModeScaleAspectFit;
  697. rightImgV.frame = CGRectMake(_locationV.width-20,_locationV.height/2-7.5,15,15);
  698. [_videoChargeView addSubview:rightImgV];
  699. UIButton *btn = [UIButton buttonWithType:0];
  700. btn.frame = CGRectMake(0, 0, _videoChargeView.width, _videoChargeView.height);
  701. [btn addTarget:self action:@selector(clikcVideoChargeBtn) forControlEvents:UIControlEventTouchUpInside];
  702. [_videoChargeView addSubview:btn];
  703. }
  704. return _videoChargeView;
  705. }
  706. -(UIView *)shopView {
  707. if (!_shopView) {
  708. //商品
  709. _shopView = [[UIView alloc]initWithFrame:CGRectMake(15, _videoChargeView ? _videoChargeView.bottom+5:_videoClassView.bottom+5, _window_width-30, 50)];
  710. _shopView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  711. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"video_shop"]];
  712. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  713. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  714. [_shopView addSubview:imageloca];
  715. _shopLabel = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, _shopView.width-50, 50)];
  716. _shopLabel.font = SYS_Font(15);
  717. _shopLabel.text = YZMsg(@"添加商品");
  718. _shopLabel.textColor = RGB_COLOR(@"#666666", 1);
  719. [_shopView addSubview:_shopLabel];
  720. UIImageView *rightImgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"askWhite_jiantou"]];
  721. rightImgV.contentMode = UIViewContentModeScaleAspectFit;
  722. rightImgV.frame = CGRectMake(_locationV.width-20,_locationV.height/2-7.5,15,15);
  723. [_shopView addSubview:rightImgV];
  724. UIButton *btn = [UIButton buttonWithType:0];
  725. btn.frame = CGRectMake(0, 0, _shopView.width, _shopView.height);
  726. [btn addTarget:self action:@selector(addShopClick) forControlEvents:UIControlEventTouchUpInside];
  727. [_shopView addSubview:btn];
  728. }
  729. return _shopView;
  730. }
  731. -(UIView *)adView{
  732. if (!_adView) {
  733. _adView =[[UIView alloc]initWithFrame:CGRectMake(15, _videoChargeView ? _videoChargeView.bottom+5:_videoClassView.bottom+5, _window_width-30, 50)];
  734. _adView.backgroundColor = RGB_COLOR(@"#15102C", 1);
  735. UIImageView *imageloca = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"publish_add"]];
  736. imageloca.contentMode = UIViewContentModeScaleAspectFit;
  737. imageloca.frame = CGRectMake(15,_locationV.height/2-7.5,15,15);
  738. [_adView addSubview:imageloca];
  739. UILabel *adLb = [[UILabel alloc]initWithFrame:CGRectMake(imageloca.right+5, 0, 80, 50)];
  740. adLb.font = SYS_Font(15);
  741. adLb.text = YZMsg(@"广告链接");
  742. adLb.textColor = RGB_COLOR(@"#666666", 1);
  743. [_adView addSubview:adLb];
  744. _adTextView = [[UITextField alloc]init];
  745. _adTextView.frame = CGRectMake(adLb.right, 0, _adView.width-adLb.right-10, 50);
  746. NSMutableAttributedString*phoneString = [[NSMutableAttributedString alloc] initWithString:YZMsg(@"请输入广告链接") attributes:@{NSForegroundColorAttributeName:RGB(150,150,150)}];
  747. _adTextView.attributedPlaceholder = phoneString;
  748. _adTextView.font = [UIFont systemFontOfSize:14];
  749. _adTextView.textColor = UIColor.whiteColor;
  750. _adTextView.backgroundColor = UIColor.clearColor;
  751. [_adView addSubview:_adTextView];
  752. }
  753. return _adView;
  754. }
  755. - (PublishShareV *)platformV {
  756. if (!_platformV) {
  757. _platformV = [[PublishShareV alloc]initWithFrame:CGRectMake(15,((_shopView) ? (_shopView.bottom+15): (_videoChargeView?(_videoChargeView.bottom+15):(_videoClassView.bottom+15))), _window_width-30, _window_width/4+30)];
  758. _platformV.backgroundColor = [UIColor clearColor];
  759. _platformV.shareEvent = ^(NSString *type) {
  760. sharetype = type;
  761. NSLog(@"share:%@",type);
  762. };
  763. }
  764. return _platformV;
  765. }
  766. -(UIButton *)publishBtn {
  767. if (!_publishBtn) {
  768. _publishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  769. // _publishBtn.frame = CGRectMake(30, _platformV.bottom+20, _window_width-60, 50);
  770. _publishBtn.frame = CGRectMake(30, ((_shopView) ? (_shopView.bottom+20): (_videoChargeView?(_videoChargeView.bottom+20):(_videoClassView.bottom+20))), _window_width-60, 50);
  771. [_publishBtn setTitle:YZMsg(@"确认发布") forState:0];
  772. [_publishBtn setTitleColor:[UIColor whiteColor] forState:0];
  773. _publishBtn.backgroundColor = Pink_Cor;
  774. _publishBtn.layer.masksToBounds = YES;
  775. _publishBtn.layer.cornerRadius = 5;
  776. [_publishBtn addTarget:self action:@selector(clickPublishBtn) forControlEvents:UIControlEventTouchUpInside];
  777. }
  778. return _publishBtn;
  779. }
  780. #pragma mark - 导航
  781. - (void)clickNaviLeftBtn {
  782. //这里重写父类 不要写 super
  783. YBWeakSelf;
  784. NSDictionary *contentDic = @{@"title":YZMsg(@"提示"),@"msg":YZMsg(@"是否放弃发布此条视频"),@"left":YZMsg(@"取消"),@"right":YZMsg(@"确定")};
  785. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  786. if (eventType == 1) {
  787. [weakSelf doSureClikc];
  788. }
  789. }];
  790. }
  791. -(void)doSureClikc {
  792. [[NSFileManager defaultManager] removeItemAtPath:_recordResult.videoPath error:nil];
  793. if (_waterVideoPath) {
  794. [[NSFileManager defaultManager] removeItemAtPath:_waterVideoPath error:nil];
  795. }
  796. [self root];
  797. }
  798. #pragma mark -添加广告
  799. -(void)isadBtnClick{
  800. _isAdBtn.selected = !_isAdBtn.selected;
  801. if (_isAdBtn.selected) {
  802. self.adView.hidden = NO;
  803. [_bgScrollView bringSubviewToFront:self.adView];
  804. if (!_shopView) {
  805. _publishBtn.frame = CGRectMake(30, ((_adView) ? (_adView.bottom+20): (_videoChargeView?(_videoChargeView.bottom+20):(_videoClassView.bottom+20))), _window_width-60, 50);
  806. }
  807. }else{
  808. self.adView.hidden = YES;
  809. if (!_shopView) {
  810. _publishBtn.frame = CGRectMake(30, ((_videoChargeView?(_videoChargeView.bottom+20):(_videoClassView.bottom+20))), _window_width-60, 50);
  811. }else{
  812. [_bgScrollView bringSubviewToFront:self.shopView];
  813. }
  814. }
  815. }
  816. #pragma mark -标签
  817. - (void)addTopicClick{
  818. videoTopicVC *topic = [[videoTopicVC alloc]init];
  819. YBWeakSelf;
  820. topic.block = ^(NSDictionary * _Nonnull dic) {
  821. weakSelf.topicDic = dic;
  822. weakSelf.topicLabel.text = minstr([dic valueForKey:@"name"]);
  823. };
  824. topic.modalPresentationStyle = 0;
  825. [self presentViewController:topic animated:YES completion:nil];
  826. }
  827. #pragma mark - 视频分类
  828. -(void)clikcVideoClassBtn {
  829. YBVideoClassVC *videoClass = [[YBVideoClassVC alloc]init];
  830. YBWeakSelf;
  831. videoClass.videoClassEvent = ^(NSDictionary * _Nonnull dic) {
  832. weakSelf.videoClassDic = dic;
  833. weakSelf.videoClassL.text = minstr([dic valueForKey:@"title"]);
  834. };
  835. videoClass.modalPresentationStyle = 0;
  836. [self presentViewController:videoClass animated:YES completion:nil];
  837. }
  838. #pragma mark - 收费
  839. -(void)clikcVideoChargeBtn {
  840. YBWeakSelf;
  841. [YBSetChargeView showInputView:_videoChargeNum complete:^(NSString * _Nonnull priceStr) {
  842. weakSelf.videoChargeNum = priceStr;
  843. weakSelf.videoChargeL.text = [NSString stringWithFormat:@"%@%@",priceStr,[common name_coin]];
  844. }];
  845. }
  846. #pragma mark - 商品
  847. - (void)addShopClick{
  848. YBWeakSelf;
  849. /*
  850. YBVideoAddGoodsVC *goodsVC = [[YBVideoAddGoodsVC alloc]init];
  851. goodsVC.goodsInfo = _shopDic;
  852. goodsVC.addGoodsEvent = ^(NSDictionary * _Nonnull originDic, NSString * _Nonnull formatJson) {
  853. weakSelf.shopLabel.text = minstr([originDic valueForKey:@"name"]);
  854. // weakSelf.goodsThumb = [originDic valueForKey:@"thumb"];
  855. weakSelf.shopDic = originDic.mutableCopy;
  856. weakSelf.shopJsonStr = formatJson;
  857. };
  858. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:goodsVC animated:YES];
  859. */
  860. // YBGoodsListVC *gVC = [[YBGoodsListVC alloc]init];
  861. // gVC.enterType = GoodsEnterType_Publish;
  862. // gVC.touserID = [Config getOwnID];
  863. // gVC.selGoodsList = @[_shopDic];
  864. // gVC.publishEvent = ^(BOOL isSel, NSDictionary *goodsDic) {
  865. // if (isSel) {
  866. // weakSelf.shopLabel.text = minstr([goodsDic valueForKey:@"name"]);
  867. // weakSelf.shopDic = goodsDic.mutableCopy;
  868. // weakSelf.goodsID = minstr([goodsDic valueForKey:@"id"]);
  869. // }else {
  870. // weakSelf.shopLabel.text = YZMsg(@"添加商品");
  871. // weakSelf.shopDic = @{}.mutableCopy;
  872. // weakSelf.goodsID = @"0";
  873. // }
  874. // };
  875. // [[YBBaseAppDelegate sharedAppDelegate]pushViewController:gVC animated:YES];
  876. RelationVideoGoodsVC *vc = [[RelationVideoGoodsVC alloc]init];
  877. vc.selectID = _goodsID;
  878. vc.block = ^(NSString * _Nonnull goodsName, NSString * _Nonnull goodsid, NSString * _Nonnull type) {
  879. dispatch_async(dispatch_get_main_queue(), ^{
  880. weakSelf.goodsID = goodsid;
  881. _shopLabel.text = goodsName;
  882. // Goodstype = type;
  883. });
  884. };
  885. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  886. }
  887. #pragma mark - 选择封面
  888. -(void)clickCovderBtn {
  889. if (!_videoAsset && [PublicObj checkNull:_recordResult.videoPath]) {
  890. [MBProgressHUD showPop:YZMsg(@"未获取到封面")];
  891. return;
  892. }
  893. YBPublishCoverVC *pvc = [[YBPublishCoverVC alloc]init];
  894. pvc.selIndex = _coverSelIndex;
  895. // pvc.videoAsset = _videoAsset;
  896. pvc.videoPath = _recordResult.videoPath;
  897. pvc.coverEvent = ^(int selIndex, UIImage *selImage) {
  898. _coverSelIndex = selIndex;
  899. _videoCoverIV.image = selImage;
  900. };
  901. pvc.modalPresentationStyle = 0;
  902. [self presentViewController:pvc animated:YES completion:nil];
  903. }
  904. - (void)dealloc {
  905. [_livePlayer removeVideoWidget];
  906. [[NSNotificationCenter defaultCenter] removeObserver:self];
  907. [[AFNetworkReachabilityManager sharedManager] stopMonitoring];
  908. }
  909. @end