I'm cocoa beginner , maybe my question is a little stupid :(
- I setup a rtsp server, build in localhost.
- I use qtmovie connect to the localhost to play a video.
- I have two buttons which can switch channel and channel 2 in my rtsp server.
It's fine every time when I click channel 1 and click play button, the qtmovieview controller bar will show negotiate->connecting->setup->playing.
After playing channel 1, when I click channel 2 and play button, the qtmovieview controllerbar only show "connecting", and nothing happen. But sometimes it works !!
Is there any memory allocation problem in the qtmovie? or am I missing something?
Below is part of my code.
(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];
}
Thank you for your help !!