[urlDict setObject:urlStr forKey:#"url"];
[urlArray addObject:urlDict];
//here in urlArray i got bellow url,
http://example.com/somevidya.AVI
How to play this url in iphone application?
You can add the url to a MPMoviePlayerController like this.
MPMoviePlayerController *videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
then present it modally like so:
[[UIApplication sharedApplication].keyWindow.rootViewController presentModalViewController:video animated:YES];
and release the videoPlayer:
[videoPlayer release];
Related
I'm implementing Skobbler SDK (v2.5) but I've an issue with firsts steps.
App crashes with this error:
[SKVectorMapView displayTrafficWithMode:]: unrecognized selector sent to instance
This is the code of AppDelegate
SKMapsInitSettings* initSettings = [[SKMapsInitSettings alloc]init];
initSettings.mapDetailLevel = SKMapDetailLevelLight;
[[SKMapsService sharedInstance] initializeSKMapsWithAPIKey:API_KEY settings:initSettings];
And this is the ViewController's code:
- (void)viewDidLoad {
[super viewDidLoad];
SKMapView *mapView = [[SKMapView alloc] initWithFrame:CGRectMake( 0.0f, 0.0f, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) )];
[self.view addSubview:mapView];
}
Could you tell me what is wrong?
Make sure you added "-ObjC" to your "other linker flag".
"Select the project and choose your target. Choose the Build settings tab and in the Other linker flags option introduce -ObjC."
from developer.skobbler.com
I can't see the MPMoviePlayerController controls when I'm streaming only audio, is this normal? All i can see is a black screen, though the audio is playing, however it works when playing video in another view. I hoped this would allow me to use the controls so i didn't have to build my own UI with AVPlayer.
My code is as follow;
self.audioPlayer = [[MPMoviePlayerController alloc] init];
self.audioPlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.audioPlayer setContentURL:self.audioUrl];
[self.audioPlayer setControlStyle:MPMovieControlModeDefault];
self.audioPlayer.scalingMode = MPMovieScalingModeAspectFit;
[self.audioPlayer.view setFrame:self.view.bounds];
[self.view addSubview:self.audioPlayer.view];
[self.view bringSubviewToFront:self.audioPlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.audioPlayer];
[self.audioPlayer prepareToPlay];
[self.audioPlayer play];
Regards
In the end i built an AVPlayer with UI rather than use MPmovieplayer.
I have a view based application (no storyboards) with a button that presents a modal view with a webview in it. The webview loads a YouTube video and the user taps it and watches the video in full screen.
When the video ends (or the user taps "done"), the video player dismisses, but for some reason I see the Main View instead of the modal view controller (and I can't invoke the modal view again with the button, although the IBAction is being called)...
The present modal view code (in the Main View controller):
SomeViewController *controller = [[[SomeViewController alloc] initWithNibName:#"SomeViewController_iPhone" bundle:nil] autorelease];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
Then, in "SomeViewController", I have a UIWebView that loads the YouTube video:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = #"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%#\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
[self.webView loadHTMLString:html baseURL:nil];
}
The video plays just fine, but when it's done, it's get dismissed and the Main View is being showed instead of the Modal View (SomeViewController).
No error is being given though.
From what I understand, the video player is also a modal view, so the hierarchy is something like this:
-- Main View
---- Modal View (SomeViewController with WebView)
-------- Video Modal View (invoked by the WebView)
So I don't get why is the Main View controller being shown after the Video is done playing, and why it doesn't let me invoke the modal view controller again...
Thanks for any help!
in my code I call tab bar controller like this:
[[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:#"tt://tabBar"]];
For the first page which tab bar called like this:
- (id)init{
if (self = [super init]) {
self.title = #"app";
UIImage* image = [UIImage imageNamed:#"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
ds.model = CreateTabModelWithCurrentSettings();
self.dataSource = ds;
}
return self;}
-(void)loadView{
self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
self.tableView.rowHeight = 80.f;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];}
As shown above.
how to remove the "back" title?
how to remove both of title?
Actually I found that the back navigate bar is previous login page's, so is there any way to release the previous login page after the tab bar controller has been called
Take a look on this tutorial. It explains how to hide the tab bar when you push a login view.
http://three20.info/article/2010-11-10-Hiding-The-iphone-Tab-Bar-With-TTNavigator
Note that it makes more sense to show your tab bar main controller, and push the login view in case the user isn't logged in. This way you can release the login view and come back to the main tab bar view.
Also, if you have issues with duplicated UINavigationBar bars, you should use the [TTURLMap from:(NSString*)URL toModalViewController:(id)target] function, which present controllers that already has UINavigationBar
`
I have taken a webview to show some HTML content in iPhone. Now I want to put some action on user events on the phone. I want to trace the tap event done on the screen by the user on that web view.
For this I have added a method
-(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {
in my code.
But the problem is when I click outside the webview it works perfectly. Bt when I tap on the web view, it does not respond. So, please tell me what should I do to acheive tap event trace on that particular web view.
Help me out.
- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
if ([[url lastPathComponent] isEqual:#"testmessage"]) {
NSLog(#"Nya");
return NO;
}
return YES;
}
HTML
<a href='testmessage'>Test</a>
or
<script>
function callObjc(){
document.location = 'testmessage';
}
</script>
<a onclick='callObjc();'>Test</a>