Showing posts with label iphone source code library. Show all posts
Showing posts with label iphone source code library. Show all posts

Tuesday, 19 June 2012

Iphone Code for MEDIA (PLAYING AUDIO AND VIDEO)


MediaViewController.h

#import <UIKit/UIKit.h>

#import <MediaPlayer/MediaPlayer.h>

#import <AVFoundation/AVFoundation.h>

@interface MediaViewController : UIViewController {

            AVAudioPlayer *audioPlayer;

            IBOutlet UISlider *sliderVolume;

            IBOutlet UIProgressView *progressAudio;}

-(IBAction)playVideo;

-(IBAction)playAudio;

-(IBAction)pauseAudio;

-(IBAction)backPlay;

-(IBAction)forwardPlay;

-(IBAction)changeVolume;

@end

MediaViewController.m

#import "MediaViewController.h"

@implementation MediaViewController

-(IBAction)playVideo{


NSString *strVideoPath =  [[NSBundle mainBundle]pathForResource:@"rangam nemali kjannula" ofType:@"mp4"];

NSURL *url = [NSURL fileURLWithPath:strVideoPath];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc]initWithContentURL:url];

self.view = player.view;

[player play];  }

-(IBAction)playAudio{         [audioPlayer play];  }

-(IBAction)pauseAudio{      [audioPlayer pause];}

-(IBAction)backPlay{

      audioPlayer.currentTime-=10;

            [audioPlayer play];  }

-(IBAction)forwardPlay{

         audioPlayer.currentTime+=10;

            [audioPlayer play];  }

-(IBAction)changeVolume{

       audioPlayer.volume  = sliderVolume.value;  }

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

    [super viewDidLoad];

NSString *strVideoPath =  [[NSBundle mainBundle]pathForResource:@"rangam nemali kjannula" ofType:@"mp4"];

            NSURL *url = [NSURL fileURLWithPath:strVideoPath];

            NSError *err;

            audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&err];

[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES]; }

-(void)updateProgress{

progressAudio.progress = audioPlayer.currentTime/audioPlayer.duration; }

Check to see if I have an Internet connection on the iPhone using the Cocoa Touch libraries





- (void) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes

NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)

{
case NotReachable:
{
NSLog(@"The internet is down.");
self.internetActive = NO;

break;

}
case ReachableViaWiFi:
{
NSLog(@"The internet is working via WIFI.");
self.internetActive = YES;

break;

}
case ReachableViaWWAN:
{
NSLog(@"The internet is working via WWAN.");
self.internetActive = YES;

break;

}
}

NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
switch (hostStatus)

{
case NotReachable:
{
NSLog(@"A gateway to the host server is down.");
self.hostActive = NO;

break;

}
case ReachableViaWiFi:
{
NSLog(@"A gateway to the host server is working via WIFI.");
self.hostActive = YES;

break;

}
case ReachableViaWWAN:
{
NSLog(@"A gateway to the host server is working via WWAN.");
self.hostActive = YES;

break;

}
}
}--------------
///Import at the beginning of your implementation file
#import "Reachability.h"

//// Where you need it
Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];

if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)){
/// Create an alert if connection doesn't work
UIAlertView *myAlert = [[UIAlertView alloc]
initWithTitle:@"No Internet Connection" message:@"You require an internet connection via WiFi or cellular network for location finding to work."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[myAlert show];
[myAlert release];
} else{
/// Whatever you want
}


//Class.h
#import "Reachability.h"
#import

- (BOOL)connected ;

//Class.m
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
Then, we can use this whenever we want to see if there is a network
if(![self connected])
{
// not connected
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection"
message:@"You must be connected to the internet to open the website."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
} else
{
// connected, do some internet stuff

}


Thursday, 14 June 2012

Sample Project on Objective C---BODY MASS INDEX(BMI)

Application overview in Iphone.


Get the complete application code and documentation at
http://www.iosbricks.blogspot.in/

Saturday, 19 May 2012

iphone source code camera & address book

In this program we have to add the AddressBook Framework in outr frameworks source…….



CameraViewController.h:



#import <UIKit/UIKit.h>
#import <AddressBookUI/AddressBookUI.h>

@interface CameraViewController : UIViewController<UIImagePickerControllerDelegate,ABPeoplePickerNavigationControllerDelegate> {

    IBOutlet UIImageView *imgView;
}
-(IBAction)photosLibrary;

-(IBAction)showAdressBook;
@end



CameraViewController.m:


#import "CameraViewController.h"

@implementation CameraViewController

-(IBAction)photosLibrary{

    UIImagePickerController *imageLibrary = [[UIImagePickerController alloc]init];
    imageLibrary.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imageLibrary.delegate = self;
    [self presentModalViewController:imageLibrary animated:YES];
   
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
   
    [picker dismissModalViewControllerAnimated:YES];
    imgView.image = image;
}
-(IBAction)showAdressBook{

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc]init];
    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{

    [peoplePicker dismissModalViewControllerAnimated:YES];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


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

@end

]