I can't see the MPMoviePlayerControls When Streaming Audio - audio

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.

Related

SKVectorMapView: unrecognized selector

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

MFSideMenu in UINavigationController not working when introduced with a modal Segue

I'm trying to integrate MFSideMenu in my project but I don't want to adopt the approach described in the GitHub depository as it defines the menu in the app delegate.
I have a login screen which will introduce a navigation controller with the main page as reported in this picture
I would like to add the support for MFSideMenu in the navigationcontroller root controller using this code:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Custom initialization
self.sideMenuController = [[SideMenuViewController alloc] init];
UINavigationController *navigationController = self.navigationController;
MFSideMenuOptions options = MFSideMenuOptionMenuButtonEnabled|MFSideMenuOptionBackButtonEnabled
|MFSideMenuOptionShadowEnabled;
MFSideMenuPanMode panMode = MFSideMenuPanModeNavigationBar|MFSideMenuPanModeNavigationController;
MFSideMenu *sideMenu = [MFSideMenu menuWithNavigationController:navigationController
sideMenuController:sideMenuController
location:MFSideMenuLocationLeft
options:options
panMode:panMode];
sideMenuController.sideMenu = sideMenu;
}
return self;
}
When I run the app the menu button appears in my navigation bar and everything seems working fine but,if I introduce the navigation controller through a modal segue (i.e. a login screen which goes to the navigation controller in case of a correct login) the button disappears.
Any idea about how to fix it?

Unexpected behavior of a Modal View displaying a YouTube video in a UIWebView

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!

How to play url in iphone application?

[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];

how to release controller after jump to other page or remove view title bar

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
`

Resources