[英]MPMoviePlayer only playing sound
試圖將我的視頻放在UITableViewCell的自定義視圖中。
videoView是一個UIView:
以下是選中單元格時的情況:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
FeedCustomCell *cell = [[FeedCustomCell alloc] init];
NSURL *url = [NSURL URLWithString:_videoPathString];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleNone;
CGRect previewFrame = CGRectMake(cell.videoView.frame.origin.x,
cell.videoView.frame.origin.y,
cell.videoView.frame.size.width,
cell.videoView.frame.size.height);
moviePlayer.view.frame = previewFrame;
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:moviePlayer.view];
[self.view bringSubviewToFront:moviePlayer.view];
[moviePlayer play];
}
這是我的手機:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"FeedCustomCell";
FeedCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
cell.username.text = [NSString stringWithFormat:@"%@", _usernameString];
cell.createdDate.text = [NSString stringWithFormat:@"%@", _createdString];
return cell;
}
當選擇單元格時,我僅向cell.videoView添加一些內容。 我做錯了嗎?
視頻正在播放聲音,但沒有視覺效果。
代替:
[self.view addSubview:moviePlayer.view];
嘗試這個:
[self.view.contentView addSubview:moviePlayer.view];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.