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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials > Tutorial Requests

Reply
 
LinkBack Thread Tools Display Modes
Old 07-14-2010, 10:46 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 13
sai07 is on a distinguished road
Default Help needed

Hi! i got no experience in Xcode or object C language. But i want to make an application for an example; if u touch the apple photo on e screen, it will say out apple. Basically is like for kids, so they can see e picture n know how to say e picture. Anyone can guide me along to where to start or show some simple tutorial on how to insert picture in e application etc,. I will getting my SDK net week... =] THANKS!!!
sai07 is offline   Reply With Quote
Old 07-14-2010, 12:45 PM   #2 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

Are you talking about it has a picture of a apple then you touch it and it says "Apple." like in a voice?
BillyGiggles is offline   Reply With Quote
Old 07-14-2010, 07:58 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 4
swelwin is on a distinguished road
Default

Yup... Can help me with it or make a simple tutorial? Thanks!
swelwin is offline   Reply With Quote
Old 07-15-2010, 03:48 PM   #4 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

ok i have a question...do you know how to create actions and buttons?

if not you will learn here

ok first here is what you will need
1) A picture of a apple or what ever you want it to say.
2)A Voice record of you or some one else saying the name of the object.
after you have these read this

First open finder and find you picture and the sound/voice
then drag the the picture into xcode in the other Resources file then you will get a message at the top there is a box that says somthing like copy items to folder or somthing ccheck that box then do the same thing with you applce picture.

Then under the FrameWorks folder in xcode right click on UIKit.framework then reveal in finder. Then scroll up (in finder) unitll you see the folder AVFoundationframework. Drag that folder into the frame works folder in xcode. WHEN THE MESSAGE COMES UP TO COPY DO NOT CHECK THE BOX TO COPY THE FILE it will give you errors.

Now go into you .h file under Classes (if you stared a new project click the second .h file)

and under the
Code:
@interface PROJECT NAME : UIViewController {
	
	
}
under the }
type

Code:
- (IBAction)apple;
that is if you sound is some one saying apple

then go to your .m file under classes (if you have a new project the send .m)

then under

Code:
#import "PROJECT NAME.h"
type

Code:
#import<AVFoundation/AVAudioPlayer.h>
then under where it says

@implementation PROJECT NAME

type

Code:
- (IBAction)apple {
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	theAudio.delegate = self;
	[theAudio play];
	
    
}
This is very important when it says

Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
change appleVoice to what ever file name the audio was
ALSO change the .mp3 to what ever kind of sound file the sound is


Now we are almost done
double click

PROJECTNAME.xib

then create a Round rect button

then go to the "Button Attributes"

find where it says "Type round rect" change it to custom

then underthat find where it says "image"
drop that menu down and find you apple piccture and select that.

now the button should have a apple.

Then click files Owner on the little box and hit control on your key board and drag to the button then it sould pop up with a menu

If you want the sound to play right whne the user hits his finger on it choose "touch down"

If you want it to be when the user takes his finger off the button to play the sound choose "Touch Up Inside"

Save that and build and go it should work

You can repeat this to have multiple sounds when you click diffrent buttons

the only step you dont have to repeat is when we typed


Code:
#import<AVFoundation/AVAudioPlayer.h>
If this didnt work or your having problems tell me and i will create you a project and email it to you if you need that just send me a private message with your email

Hope i helped
BillyGiggles is offline   Reply With Quote
Old 07-16-2010, 08:11 AM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 47
rob.mccarthy is on a distinguished road
Default

Hi BillyGiggles, seems you know a bit about this

Is it possible to control the sound in one class from another? I want to be able to stop some sounds in one class/nib I have when accessing others in another class/nib?

Thanks

Quote:
Originally Posted by BillyGiggles View Post
ok i have a question...do you know how to create actions and buttons?

if not you will learn here

ok first here is what you will need
1) A picture of a apple or what ever you want it to say.
2)A Voice record of you or some one else saying the name of the object.
after you have these read this

First open finder and find you picture and the sound/voice
then drag the the picture into xcode in the other Resources file then you will get a message at the top there is a box that says somthing like copy items to folder or somthing ccheck that box then do the same thing with you applce picture.

Then under the FrameWorks folder in xcode right click on UIKit.framework then reveal in finder. Then scroll up (in finder) unitll you see the folder AVFoundationframework. Drag that folder into the frame works folder in xcode. WHEN THE MESSAGE COMES UP TO COPY DO NOT CHECK THE BOX TO COPY THE FILE it will give you errors.

Now go into you .h file under Classes (if you stared a new project click the second .h file)

and under the
Code:
@interface PROJECT NAME : UIViewController {
	
	
}
under the }
type

Code:
- (IBAction)apple;
that is if you sound is some one saying apple

then go to your .m file under classes (if you have a new project the send .m)

then under

Code:
#import "PROJECT NAME.h"
type

Code:
#import<AVFoundation/AVAudioPlayer.h>
then under where it says

@implementation PROJECT NAME

type

Code:
- (IBAction)apple {
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	theAudio.delegate = self;
	[theAudio play];
	
    
}
This is very important when it says

Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
change appleVoice to what ever file name the audio was
ALSO change the .mp3 to what ever kind of sound file the sound is


Now we are almost done
double click

PROJECTNAME.xib

then create a Round rect button

then go to the "Button Attributes"

find where it says "Type round rect" change it to custom

then underthat find where it says "image"
drop that menu down and find you apple piccture and select that.

now the button should have a apple.

Then click files Owner on the little box and hit control on your key board and drag to the button then it sould pop up with a menu

If you want the sound to play right whne the user hits his finger on it choose "touch down"

If you want it to be when the user takes his finger off the button to play the sound choose "Touch Up Inside"

Save that and build and go it should work

You can repeat this to have multiple sounds when you click diffrent buttons

the only step you dont have to repeat is when we typed


Code:
#import<AVFoundation/AVAudioPlayer.h>
If this didnt work or your having problems tell me and i will create you a project and email it to you if you need that just send me a private message with your email

Hope i helped
rob.mccarthy is offline   Reply With Quote
Old 07-16-2010, 08:56 AM   #6 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

haha not really im 13 years old but i have a app that im working on that has around a hundred sounds being played

are you saying when you press a button it plays the sound and if you hit another button it stops the sound?

or

When you hit one button it plays the sound and when you hit another button it switches views with the sound going

or

When you hit one button it plays the sound and when you hit another button it switches views and the sound stops
BillyGiggles is offline   Reply With Quote
Old 07-16-2010, 08:57 AM   #7 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

oh i think i get it...

one more option haha

are you saying that when you hit a button on another view it plays the sound from the first view?
BillyGiggles is offline   Reply With Quote
Old 07-16-2010, 09:32 AM   #8 (permalink)
iPhone Developer
 
spikeyfish2's Avatar
 
Join Date: Aug 2009
Location: Manchester, UK
Posts: 140
spikeyfish2 is on a distinguished road
Send a message via MSN to spikeyfish2 Send a message via Skype™ to spikeyfish2
Default

Quote:
Originally Posted by BillyGiggles View Post
oh i think i get it...

one more option haha

are you saying that when you hit a button on another view it plays the sound from the first view?
I think he wants to be able to stop the sound from another class.

To OP: You can do this, yes. At the top of the .m where you want to control the sound, just type:

Code:
#import "ViewControllerWhereTheOriginalSoundIs.h
Of course, you need to change the file name to import to the one where the sound is initiated, and defined
__________________
 iMac i3 3.06GHz, 4GB RAM (Mid-2010)
 Magic Trackpad and Wireless Keyboard
 Licensed iPhone Developer (Alex Blundell)
 iPod Touch (3rd Generation)
 iPad 32GB WiFi
 Support Me! Download:
***iTalk Messenger
***Tennis
***iTalk Messenger Lite!
spikeyfish2 is offline   Reply With Quote
Old 07-16-2010, 09:35 AM   #9 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 47
rob.mccarthy is on a distinguished road
Default

Quote:
Originally Posted by spikeyfish2 View Post
I think he wants to be able to stop the sound from another class.

To OP: You can do this, yes. At the top of the .m where you want to control the sound, just type:

Code:
#import "ViewControllerWhereTheOriginalSoundIs.h
Of course, you need to change the file name to import to the one where the sound is initiated, and defined
I have the
Code:
#import "ViewControllerWhereTheOriginalSoundIs.h
at the top, however it doesn't recognise it when I call it ( i.e. [audioPlayer1 stop])

What do I do to get it recognising it?
rob.mccarthy is offline   Reply With Quote
Old 07-16-2010, 09:41 AM   #10 (permalink)
iPhone Developer
 
spikeyfish2's Avatar
 
Join Date: Aug 2009
Location: Manchester, UK
Posts: 140
spikeyfish2 is on a distinguished road
Send a message via MSN to spikeyfish2 Send a message via Skype™ to spikeyfish2
Default

Quote:
Originally Posted by rob.mccarthy View Post
I have the
Code:
#import "ViewControllerWhereTheOriginalSoundIs.h
at the top, however it doesn't recognise it when I call it ( i.e. [audioPlayer1 stop])

What do I do to get it recognising it?
Just before I type the code, to make it easier to understand, I'm going to write ViewControllerWhereTheOriginalSoundIs to OrigSoundView.

I'm no expert, but I think it should be one of these:

Code:
[[OrigSoundView audioPlayer1] stop];
[OrigSoundView.audioPlayer1 stop];
I hope one of those works for you. I always work of trial and error, as I sometimes can't remember things - and this is a prime example!

Good Luck
__________________
 iMac i3 3.06GHz, 4GB RAM (Mid-2010)
 Magic Trackpad and Wireless Keyboard
 Licensed iPhone Developer (Alex Blundell)
 iPod Touch (3rd Generation)
 iPad 32GB WiFi
 Support Me! Download:
***iTalk Messenger
***Tennis
***iTalk Messenger Lite!
spikeyfish2 is offline   Reply With Quote
Old 07-16-2010, 09:48 AM   #11 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 47
rob.mccarthy is on a distinguished road
Default

Quote:
Originally Posted by spikeyfish2 View Post
Just before I type the code, to make it easier to understand, I'm going to write ViewControllerWhereTheOriginalSoundIs to OrigSoundView.

I'm no expert, but I think it should be one of these:

Code:
[[OrigSoundView audioPlayer1] stop];
[OrigSoundView.audioPlayer1 stop];
I hope one of those works for you. I always work of trial and error, as I sometimes can't remember things - and this is a prime example!

Good Luck
Hi,

I get it compiling ok with

Code:
[[OrigSoundView audioPlayer1] stop];
However, I get a warning that 'OrigSoundView' may not respond to 'audioPlayer1'

Then when I do the relevant action in my app on the simulator/device it crashes :s

note: I am just using your code as example, I have been changing to my code names etc
rob.mccarthy is offline   Reply With Quote
Old 07-16-2010, 10:00 AM   #12 (permalink)
iPhone Developer
 
spikeyfish2's Avatar
 
Join Date: Aug 2009
Location: Manchester, UK
Posts: 140
spikeyfish2 is on a distinguished road
Send a message via MSN to spikeyfish2 Send a message via Skype™ to spikeyfish2
Default

Quote:
Originally Posted by rob.mccarthy View Post
Hi,

I get it compiling ok with

Code:
[[OrigSoundView audioPlayer1] stop];
However, I get a warning that 'OrigSoundView' may not respond to 'audioPlayer1'

Then when I do the relevant action in my app on the simulator/device it crashes :s

note: I am just using your code as example, I have been changing to my code names etc
In the initialisation class of the audioPlayer, setup a new method like this:

Code:
-(void)stopAudioPlayer1 {

}
Inside, stop the audioPlayer as you normally would. Then, in the secondary class (where you want to stop it) call

Code:
[OrigSoundView stopAudioPlayer1];
That should work
__________________
 iMac i3 3.06GHz, 4GB RAM (Mid-2010)
 Magic Trackpad and Wireless Keyboard
 Licensed iPhone Developer (Alex Blundell)
 iPod Touch (3rd Generation)
 iPad 32GB WiFi
 Support Me! Download:
***iTalk Messenger
***Tennis
***iTalk Messenger Lite!
spikeyfish2 is offline   Reply With Quote
Old 07-16-2010, 10:09 AM   #13 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 47
rob.mccarthy is on a distinguished road
Default

Quote:
Originally Posted by spikeyfish2 View Post
In the initialisation class of the audioPlayer, setup a new method like this:

Code:
-(void)stopAudioPlayer1 {

}
Inside, stop the audioPlayer as you normally would. Then, in the secondary class (where you want to stop it) call

Code:
[OrigSoundView stopAudioPlayer1];
That should work
Thanks again spikeyfish2

However, this is doing the exact same as it was before. Compiling with a warning and then crashing out when it gets called.

Just to confirm I am calling the .h file of the original class in the .m file of the new class. Am I to call the original .h file anywhere else (i.e. like the .h file of the new class).

This has been bugging me for dayys, and I am glad of your help!
rob.mccarthy is offline   Reply With Quote
Old 07-19-2010, 12:44 AM   #14 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 13
sai07 is on a distinguished road
Default

Hi BillyGiggles!Thanks for your help, however there is delay in my SDK. So i will be testing is on wednesday. I will reply to you ASAP. Thanks in advance!
sai07 is offline   Reply With Quote
Old 07-19-2010, 03:37 AM   #15 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 47
rob.mccarthy is on a distinguished road
Default

Does anyone else know how I can call my AudioPlayer from another class?



Seem to be struggling to get this sorted.

Cheers!
rob.mccarthy is offline   Reply With Quote
Old 07-19-2010, 09:50 PM   #16 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

just import the audio player at the top next to

Code:
#import "PROJECT NAME.h"
so it looks like
Code:
#Import "PROJECT NAME.h"
#import <AVFoundation/AVAudioPlayer.h>
BillyGiggles is offline   Reply With Quote
Reply

Bookmarks

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
» Stats
Members: 175,696
Threads: 94,139
Posts: 402,961
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jasper_muc
Powered by vBadvanced CMPS v3.1.0

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