Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
Ive tried implementing a MPMoviePlayerController to play mp3's. Problem is my app is entirely in portrait-mode, whereas when the MPMoviePlayer loads it rotates the screen to landscape-mode.

Im guessing there is a property that should adress this, but after messing around with both movieControlMode and scalingMode it persists on appearing in landscape.

Code:
	// Init:		MPPlayer
	mpPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:soundPath]];
		
	// Ive tried all these: MPMovieControlModeDefault, MPMovieControlModeVolumeOnly, MPMovieControlModeHidden.
	mpPlayer.movieControlMode = MPMovieControlModeDefault;
						 
	// Ive tried all these MPMovieScalingModeNone, MPMovieScalingModeAspectFit, MPMovieScalingModeAspectFill, MPMovieScalingModeFill.
	mpPlayer.scalingMode = MPMovieScalingModeAspectFill;
		
	// Release:		Release object after play
	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMovieFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

	// Play:		Sound
	[mpPlayer play];

Any ideas how I can make it stick to portrait-mode?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Why are you using the movie player to play MP3s? Shouldn't you just use an audio player, like Audio Toolbox or Audio Queue or ...?
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
I guess I got scared when I tried reading up on them :p I got the impression that to play a single mp3-file I had to write an inmense amount of code, and even include some code in c. Perhaps Im wrong?

I can use:
Code:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];

But that makes the view rotate and then rotate back, causing flicker.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
It did diminish the flickering somewhat, so half way there :)

Im not entirely sure that the flickering will persist when running on a real device though. The screen does not seem to rotate at all, but rather its the iphone simulator that rotates - probably standard behaviour when loading a MPMediaPlayerController...? So maby this isnt even an issue, and the app will work without rotating when on a real device :)

Problem is I cant try it out since Im having awful problems with signing my app to my iPhone...which seems to be very common *cant imagine why they made it so complicated*
 

ghayenga

macrumors regular
Jun 18, 2008
190
0
I guess I got scared when I tried reading up on them :p I got the impression that to play a single mp3-file I had to write an inmense amount of code, and even include some code in c. Perhaps Im wrong?

I can use:
Code:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];

But that makes the view rotate and then rotate back, causing flicker.

The MPMoviePlayer does that. Always. There's nothing you can do about it.

You should use the new AVAudioPlayer instead. Much simpler than Audio Queue or Core Audio.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
I can. To keep the script-kiddies out. ;)

I resent that ;) hehe


ghayenga: I havent heard about that one, but if it's simpler then Im game :)
However, I would like to be able to see my other view with its text when playing the sound. Is that possible, or does the AVAudioPlayer switch to another player-gui?
And is it only supported in 2.2?
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
Oops, you're not a dastardly script-kiddie, are you? :eek:

I dont know if my skills are even up to par with a script-kiddie when it comes to iPhone-development :eek: :p

Anyway, Im trying my best, and this forum is invaluable, so thank you for all the help Ive been getting :)
 

ghayenga

macrumors regular
Jun 18, 2008
190
0
I resent that ;) hehe


ghayenga: I havent heard about that one, but if it's simpler then Im game :)
However, I would like to be able to see my other view with its text when playing the sound. Is that possible, or does the AVAudioPlayer switch to another player-gui?
And is it only supported in 2.2?

No it has no interface of it's own. So no problem for you there. It was introduced in 2.2, so yes 2.2 and up only.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
No it has no interface of it's own. So no problem for you there. It was introduced in 2.2, so yes 2.2 and up only.

Ok, thanks a lot :) I think Ill keep it simple without a stop-button or any other gui, though, since the sound-files are all shorter than 5 seconds.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.