Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-21-2009, 08:22 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: London
Posts: 15
Default Puzzling Video Problem

Puzzling Video Problem

I am makingan application that plays a random video when I make a sound. It works perfectly when I am using the iphone simulator on the Mac. However it does not work correctly on my ipodtouch basically when I make a sound it will play a random video but it will not play another video when I make a sound. But this problem does not occur on the simulator.

Does anyone have any ideas as to why? the code can be seen below

and merry christmas

Code:
#import <MediaPlayer/MediaPlayer.h>


#import "AskViewController.h"


@implementation AskViewController
@synthesize imageView;




- (void)viewDidLoad {
    [super viewDidLoad];
	
	NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
	
	NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
							  [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
							  [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
							  [NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,
							  [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
							  nil];
	
	NSError *error;
	
	recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
	
	if (recorder) {
		[recorder prepareToRecord];
		recorder.meteringEnabled = YES;
		[recorder record];
		levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.03 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];
	} else
		NSLog([error description]);	
}


- (void)levelTimerCallback:(NSTimer *)timer {
	[recorder updateMeters];
	
	const double ALPHA = 0.05;
	double peakPowerForChannel = pow(10, (0.05 * [recorder peakPowerForChannel:0]));
	lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;	
	
	if (lowPassResults > 0.65)
		
		NSLog: [self micHadNoise];
	
	
	//// micHadNoise is essential
	
}

- (void) micHadNoise {
	
	
	
		
		int r = arc4random() % 9;
		
		NSBundle *bundle = [NSBundle mainBundle];
		
		NSString* movieName = [NSString stringWithFormat:@"me%d", r];
		NSString *moviePath = [bundle pathForResource:movieName ofType:@"m4v"];
		
		NSURL *movieURL;
		
		if (moviePath)
		{
			movieURL = [NSURL fileURLWithPath:moviePath];
		}
		
		if (movieURL != nil) {
			MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
			
			// Register to receive a notification when the movie has finished playing. 
			[[NSNotificationCenter defaultCenter] addObserver:self
													 selector:@selector(moviePlayBackDidFinish:)  
														 name:MPMoviePlayerPlaybackDidFinishNotification 
													   object:moviePlayer];
			
			moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
			moviePlayer.movieControlMode = MPMovieControlModeHidden;
			moviePlayer.backgroundColor = [UIColor clearColor];
			
			[moviePlayer play];
			
		}
		
	}
	
	
	
	
	
	
	







- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self becomeFirstResponder];
}
- (BOOL) canBecomeFirstResponder {
    return YES;
}
- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;

	
}
- (void)dealloc {
	
	
    [super dealloc];
	
	
}

- (void)moviePlayBackDidFinish:(NSNotification*)aNotification{
	
	MPMoviePlayerController* theMovie = [aNotification object];
	[[NSNotificationCenter defaultCenter] removeObserver:self 
													name:MPMoviePlayerPlaybackDidFinishNotification
												  object:theMovie];
	
	[theMovie release];
	
	
}

@end
mrsaxon10 is offline   Reply With Quote
Reply

Bookmarks

Tags
movie, sound, video

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 340
20 members and 320 guests
ADY, Dani77, e2applets, Herbie, JasonR, keeshux, linkmx, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:33 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0