我是可可初学者,也许我的问题有点愚蠢:(
每次单击频道1并单击播放按钮时都可以,qtmovieview控制器栏将显示协商 - >连接 - >设置 - >播放。
播放频道1后,当我点击频道2和播放按钮时,qtmovieview控制栏只显示“正在连接”,没有任何反应。但有时候它有效!!
qtmovie中是否有内存分配问题?还是我错过了什么?
以下是我的代码的一部分。
(void)play:(id)sender{
NSLog(@"Play");
NSURL *url3=[NSURL URLWithString:@"rtsp://127.0.0.1:8554/"];
qtmovie=[QTMovie movieWithURL:url3 error:nil];
@try {
[_movieView setControllerVisible: YES];
[_movieView setMovie: qtmovie];
[qtmovie play];
[_movieView display];
}
@catch (NSException *exception) {
NSLog(@"%@",[exception name]);
}
}
-(IBAction)clickchannel1:(id)sender
{
NSTimer * timer=nil;
[_label setStringValue:@"Channel1 Playing"];
if(channel==2){
[qtmovie stop];
[_movieView setMovie:nil];
[timer invalidate];
timer = nil;
CloseChannel(channel);
}
channel = 1;
OpenChannel(channel);
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showBufferLevel:) userInfo:nil repeats:YES];
}
-(IBAction)clickchannel2:(id)sender;
{
[testThread release];
NSTimer * timer=nil;
[_label setStringValue:@"Channel2 Playing"];
if(channel==1){
[_movieView setMovie:nil];
[timer invalidate];
timer = nil;
CloseChannel(channel);
}
//[qtmovie play];
channel = 2;
OpenChannel(channel);
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showBufferLevel:) userInfo:nil repeats:YES];
}
感谢您的帮助!