GPUImageView Integration in my project - xcode4.5

What I am trying to do is this.
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url2 = [[NSBundle mainBundle] URLForResource:#"NAN" withExtension:#"mov"];
GPUImageMovie *movie2 = [[GPUImageMovie alloc] initWithURL:url2];
movie2.playAtActualSpeed = YES;
filter0 = [[GPUImageSepiaFilter alloc] init];
[movie2 addTarget:filter0];
[filter0 addTarget:view0]; // view0 is a GPUImageView taken in nib
[self recordVideo];
isRecording = YES;
[movie2 startProcessing];
[movieWriter setCompletionBlock:^{
if (isRecording) {
[self stopRecording];
isRecording = NO;
} }];
}
-(void)recordVideo {
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:#"file.mov"];
NSURL *url = [NSURL fileURLWithPath:path];
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:path error:nil];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:url size:CGSizeMake(640, 480)];
[filter0 addTarget:movieWriter];
[movieWriter startRecording];
}
-(void)stopRecording {
[movieWriter finishRecording];
}
But this is not working at all. I always get a black video with this code. There is no crash, I get a black video with the same duration as of original video. Has anyone faced the same issue. Kindly help.
Any help would be great.

Related

How to get a video PHAsset disk file size?

I'm trying to determine the file size on disk of a PHAsset video.
The following code is returning am error "The file “IMG_0188.mov” couldn’t be opened because you don’t have permission to view it."
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHVideoRequestOptionsVersionOriginal;
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset *avAsset, AVAudioMix *audioMix, NSDictionary *info) {
videoURL = [(AVURLAsset*)avAsset URL];
NSNumber *videoDiskFileSize;
NSError *error;
[videoURL getResourceValue:&videoDiskFileSize forKey:NSURLFileSizeKey error:&error];
if(error){
NSLog(#"ERROR %#", error.localizedDescription);
}
NSLog(#"size is %f",[videoDiskFileSize floatValue]/(1024.0*1024.0));
}];
Here's the correct way to do it.
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHVideoRequestOptionsVersionOriginal;
[[PHImageManager defaultManager] requestExportSessionForVideo:asset options:options exportPreset:AVAssetExportPresetHighestQuality resultHandler:^(AVAssetExportSession *exportSession, NSDictionary *info) {
CMTime videoDuration = CMTimeMultiplyByFloat64(exportSession.asset.duration, 1);
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, videoDuration);
NSLog(#"Byyte size = %lld", exportSession.estimatedOutputFileLength);
videoSize = exportSession.estimatedOutputFileLength;
}];

Method cellForRowAtIndexPath method was not get called

Am a beginner in iOS, am creating an application with the help of table view. I just run my application, while running the app, the app does not calling the method cellForRowIndexPath. Am using Json as web service. In the output screen, the parsing data is shown but it is not get display in simulator. i put breakpoint and i understood the cellForRowIndexPath path was not called. I drag datasourse and data delegate to files onner of xib file. but nothing is occurring... the table view is get displaying but there is no content... am screwed.. Any one please help me...
#implementation MSPackagesController
#synthesize packageTable;
#synthesize packages;
#synthesize mainCtrl;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
}
-(void)parseData {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
MSJsonParser *parser = [[MSJsonParser alloc]initWithParserType:kPackagesParsing];
parser._parserSource = self;
[parser requestParsingWithUrl:PACKAGES_LIST_URL];
}
-(void)sharePackageFromCell:(UIButton*)btn
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
NSString *title = [[self.packages objectAtIndex:btn.tag] packageName];
/*NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:btn.tag] picture]];
NSData *imgdata = [NSData dataWithContentsOfURL:imgUrl];
UIImage *image = [UIImage imageWithData:imgdata];*/
// NSURL *imgUrl = [NSURL URLWithString:[[self.packages objectAtIndex:btn.tag] picture]];
NSString *desc = [[self.packages objectAtIndex:btn.tag] packageDescription];
NSString *message = #"Visit GlamZapp in AppStore";
UIActivityViewController *activityCtrl = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:title,desc,message, nil] applicationActivities:nil];
activityCtrl.excludedActivityTypes = #[UIActivityTypePrint,UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAssignToContact];
activityCtrl.completionHandler = ^(NSString *activityType, BOOL completed)
{
NSLog(#" activityType: %#", activityType);
NSLog(#" completed: %i", completed);
};
[self.mainCtrl presentViewController:activityCtrl animated:YES completion:^{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [packages count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
MSPackagesCell *cell = (MSPackagesCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *cells = [[NSBundle mainBundle]loadNibNamed:[Common checkDeviceforController:#"MSPackagesCell"] owner:nil options:nil];
for (id eachObject in cells) {
cell = eachObject;
break;
}
//cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell...
// NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:indexPath.row]picture]];
//[cell.promoImg setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:#"slider_dummy.jpg"] andSize:cell.promoImg.frame.size];
cell.PackageName.text = [[self.packages objectAtIndex:indexPath.row] packageName];
cell.PackageDescription.text = [[self.packages objectAtIndex:indexPath.row] packageDescription];
// NSMutableAttributedString *strikedPrice = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ] ];
// [strikedPrice addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0, [strikedPrice length])];
//cell.oldPriceLabel.attributedText = strikedPrice;
cell.PriceLabel.text = [NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ];
//[string appendFormat:#"%#\r\n", message];
// cell.promocodelabel.text = [NSString stringWithFormat:#"Promo code: %#",[[self.packages objectAtIndex:indexPath.row] promoCode]];
cell.ShareButton.tag = indexPath.row;
[cell.ShareButton addTarget:self action:#selector(sharePackageFromCell:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// MSPackageDetailsController *promDet = [[MSPackageDetailsController alloc]initWithNibName:[Common checkDeviceforController:#"MSPackageDetailsController"] bundle:nil];
// promDet.delegate = self;
// promDet.offerId = [[self.packages objectAtIndex:indexPath.row] promoId];
// promDet.title = [[self.packages objectAtIndex:indexPath.row] promoTitle];
// [self.delegate didSelectPromotion:promDet];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)foundPackagesData:(NSArray *)packa
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
self.packages = packa;
[self.packageTable reloadData];
}
-(void)connectionFailed
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
I think you have not added UITableviewDataSource and UITableViewDelegate in your .h file
Add UITableViewDataSource,UITableViewDelegate in interface (.h) file
#interface MSPackagesController : UIViewController <UITableViewDataSource,UITableViewDelegate>

Warning: Attempt to present UINavigationController on SampleViewController: whose view is not in the window hierarchy

i have try all the solution in this forum but still cannot solve. Can anybody help me out with these problem? i want the app to open the inboxData class that contain a tableView when the NSUserDefault read the key #"url" from Urban Airship..
this is from SampleViewController class;
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *action_9 = [defaults objectForKey:#"url"];
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"url"] isEqualToString:#"aa9"])
{
inboxData *screen=[[inboxData alloc]initWithNibName:#"inboxData" bundle:nil];
screen.strGetTableSelect=#"1";
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:screen];
[self presentModalViewController:navigationController animated:YES];
}
}
it return with these error..
Warning: Attempt to present UINavigationController on SampleViewController whose view is not in the window hierarchy
Your SampleViewController not in the Window hierarchy, You need to set in window.
In your appDelegate, do like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[SampleViewController alloc] initWithNibName:#"SampleViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
If you are using storyboad, Use like this in didFinishLaunchingWithOptions method,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone"
                                                             bundle: nil];
 
    SampleViewController *mainViewController = (SampleViewController*)[mainStoryboard
                                                       instantiateViewControllerWithIdentifier: #"SampleViewController"];
 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window setRootViewController:navigationController];
    [self.window setBackgroundColor:[UIColor whiteColor]];
    [self.window makeKeyAndVisible];
 
    return YES;
}
In your view controller,
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *action_9 = [defaults objectForKey:#"url"];
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"url"] isEqualToString:#"aa9"])
{
inboxData *screen=[[inboxData alloc]initWithNibName:#"inboxData" bundle:nil];
screen.strGetTableSelect=#"1";
[self presentModalViewController:screen animated:YES];
}
}

Retrieving data from a plist

`Okay so I am trying to pull questions and possible answers from a plist file I have created
<key>Question1</key>
<string></string>
<key>Answer1</key>
<array/>
<key>4</key>
<string>A</string>
<key>2</key>
<string>B</string>
<key>3</key>
<string>C</string>
So I have tried to do this in code from looking a various tutorials, I am only new to this so I know I have it all wrong
so then I want to place the question in an label created in the storyboard and the same with the possible answers????
`
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *listPath = [[self docDir]stringByAppendingPathComponent:#"work.plist"];
if (![[NSFileManager defaultManager]fileExistsAtPath:listPath]) {
[[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle]pathForResource:#"work" ofType:#"plist"]toPath:listPath error:nil];
}
NSMutableArray *array = [NSMutableArray arrayWithContentsOfFile:listPath];NSLog(#"count: %i", [array count]);
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
propertyListFromData:#"work.plist";
self.firstQuestion = [temp objectForKey:#"Question1"];
self.firstanswer = [NSMutableArray arrayWithArray:[temp objectForKey:#"Answer"]];`
TRY this too.
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [path objectAtIndex:0];
NSString *plistpath = [documentsPath stringByAppendingPathComponent:#"question.plist"];
NSMutableArray *savedStock = [[NSMutableArray alloc] initWithContentsOfFile:plistFilePath];
for (int i=0; i<[savedStock count]; i++)
{
[A-array addObject:[[savedStock objectAtIndex:i] valueForKey:#"A"]];
[B-array addObject:[[savedStock objectAtIndex:i] valueForKey:#"B"]];
}

i had some images in resultstring i want to display it in tableview

i had some images in resultstring ,resultstring is what i get from the server ,it contains images ,i want that images and display it in tableview
my code is
viewdidload
{
NSString *urlVal = #"http://at.azinova.info/green4care/iphone/viewImage.php?id=";
NSString *urlVal1 = [urlVal stringByAppendingString:selectedCountryw];
NSURL *url1 = [NSURL URLWithString:urlVal1];
//NSURL *url1 = [NSURL URLWithString:urlVal];
NSString *resultString = [NSString stringWithContentsOfURL:url1 encoding:NSUTF8StringEncoding error:nil];
NSArray *arycountries1 = [resultString componentsSeparatedByString:#","];
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:#" Message" message:resultString delegate:self
cancelButtonTitle:#"OK" otherButtonTitles:nil];
[loginalert show];
[loginalert release];
//arraycountries = [[NSArray alloc]initWitho:arycountries1];
arraycountries = [[NSArray alloc]initWithArray: arycountries1];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [arraycountries count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.imageView.image = [UIImage imageNamed:[arraycountries objectAtIndex:indexPath.row]];
// Configure the cell...
return cell;
}
please help
thankzzzzz
What you described is much like a message borad with images, there is a twitter open source project tweetero: http://code.google.com/p/tweetero/ You can take a look at MessageListController and ImageLoader.
In generally, you could do like this:
1) Send async request to server to get message date(not images)
2) reload the table data, and send the image loader request for each uiimageview.
3) set the uiimageview when the image is loaded. A default loading image can be used until the real image is loaded.

Resources