Question

Okay maybe the headline is somehow disturbing, I hope to state this so you can understand my problem. So I have a scrollview which has paging enabled. I want to build something like iOS Photo App.
I load the photos and videos which are on the device via ALAsset and store them in a group.
Now i want to present each object on a separate subview of the scrollview.
For the pictures it is working fine. But for videos I cant make it work.
Here is what i did and what did not work:
First:

UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
NSString *embedHTML = [NSString stringWithFormat: @"<html><head><style></style></head><body>\
<video id='video_with_controls' width=\"%0.0f\" height=\"%0.0f\" controls>\
<source src='%@' type='video/MOV'/></video><ul>\
</body></html>", self.mainScrollView.frame.size.width, self.mainScrollView.frame.size.height, [assetRepresentation url]];
[webView loadHTMLString:embedHTML baseURL:nil];

then:

UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
NSString* embedHTML = [NSString stringWithFormat:@"<video controls> <source src=\"%@\"> </video>", [assetRepresentation url];
[webView loadHTMLString:embedHTML baseURL:nil];

Also I tried to store it in NSData first and then load it from there, but that causes memory problems and wont work.

Any help is highly appreciated!

Edit: As I think UIWebView is the thing that matches the iOS App visually at most, I want to use this and not for example the MPMoviePlayer .. if I am wrong there I would be glad to know how / what else looks like the original App

Was it helpful?

Solution

I guess the video url is local thats why its not working in UiWebView

so the solution would be this: in delegate method webviewdidstartload,set up MPmovieplayer controller to play inside a UiView and yes it will look like original app as you will be playing it in a view

something like this:

Add MPMoviePlayerController's view to a UIView

OTHER TIPS

When you movie file is located locale you must set the baseURL to your MainBundle and put the full path in the "src"-tag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top