I have added few videos inSame cell using tableview. Each cell is having its own webview. Video is played in webview using the following code
NSString *embedHTML = @"<html><head>\<style type=\"text/css\">\body {\background-color:transparent;\color: white;\}\</style>\<script>\function load({document.getElementById(\"yt\").play();}\</script>\</head><body onload=\"load()\"style=\"margin:0\">\<video id=\"yt\" src=\"%@\" \width=\"%0.0f\" height=\"%0.0f\" autoplay controls></video>\</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, videoView.frame.size.width, videoView.frame.size.height,thumbnailImageLink];
[videoView loadHTMLString:html baseURL:nil];
It works absolutely fine. It displays the thumbnail video with play button on it. Tapping on Play button opens up the video player in Full Screen mode with all the controls.
Now the main issue is
When I press the done button the full screen mode goes away Well, thats as expected
But the downloading of the video Still continues. Not at all Good
So Say,
I opened up Video1 then I press on Done button, then I opened video2 But because video1 is still downloading, video2 is getting less internet speed.
So the Question is, Is there anyway out to forcefully stop Downloading when the Done button on full screen is pressed?
Note: There is a list of videos i.e. n videos = n webviews So it is not possible to detect Which webview is playing the video. If I am able to access the webview then I would have reloaded it So that the downloading can get stopped and it gets fresh content which does not start until I tap the thumbnail.
To be more Specific I can access when the video is played and when Done button is pressed using
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayFinished:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
And can be accessed through
BOOL isVideoInFullScreenMode;
-(void)videoPlayStarted:(NSNotification *)notification{
//Your stuff here
isVideoInFullScreenMode = YES;
}
-(void)videoPlayFinished:(NSNotification *)notification{
//Your stuffs here
isVideoInFullScreenMode = NO;
}
You can’t control what’s happening in the webview.
I think it is a design issue. Webviews are not magic cure to all. You need to write the code yourself if you want to control it.
I also hope you’ve bugged this with apple (http://bugreporter.apple.com).