problem description
PLPlayer RTMP live stream is played for the first time, the sound and video do not match, and the picture and sound are different for more than ten seconds
the environmental background of the problems and what methods you have tried
encapsulate a player and play it as soon as you enter the interface. There is still a problem trying to come in and pause for a few seconds before playing.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
PLPlayerOption * option = [PLPlayerOption defaultOption];
[option setOptionValue:@15 forKey:PLPlayerOptionKeyTimeoutIntervalForMediaPackets];
NSURL *url = [NSURL URLWithString:self.url];
self.player = [PLPlayer playerWithURL:url option:option];
self.player.delegate = self;
self.player.playerView.frame = self.frame;
[self addSubview:self.player.playerView];
[self.player play];
//
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(playerViewTap:)];
[self addGestureRecognizer:tap];
self.cover = [[UIView alloc]init];
self.cover.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
[self addSubview:self.cover];
[self.cover mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.bottom.equalTo(self);
}];
//
self.btnFullScreen = [[UIButton alloc]init];
[self.btnFullScreen setImage:[UIImage imageResize:[UIImage imageNamed:@"ico_-full-screen"] andResizeTo:CGSizeMake(25, 25)] forState:(UIControlStateNormal)];
[self.btnFullScreen setImage:[UIImage imageNamed:@""] forState:(UIControlStateSelected)];
[self.cover addSubview:_btnFullScreen];
[self.btnFullScreen mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.offset(-5);
make.bottom.equalTo(self->_cover).offset(-10);
}];
[self.btnFullScreen addTarget:self action:@selector(fullScreen:) forControlEvents:(UIControlEventTouchUpInside)];
//
self.currentTime = [[UILabel alloc]init];
self.currentTime.font = [UIFont systemFontOfSize:15];
self.currentTime.text = @"00:00:00";
self.currentTime.textAlignment = NSTextAlignmentLeft;
self.currentTime.textColor = [UIColor whiteColor];
[_cover addSubview:self.currentTime];
[self.currentTime mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self->_cover).offset(10);
make.centerY.equalTo(self->_btnFullScreen);
}];
what result do you expect? What is the error message actually seen?
the first time loading sound can correspond to the video picture