Bonjour à tous,
Je voudrais lancer une video après avoir cliqué sur un bouton.
J ai bidouillé un petit code mais ça ne marche pas. En fait c est un code qui se situait dans le - (void)loadView et la ça marchait très bien. Au lancement de la vue la video jouait direct. J ai copié le code et créé un bouton IBAction et la ça ne marche pas.
Quelqu un pourrait il me dire ce qu il faut faire pour arranger ça ?
Je cré une baseViewApplication et dans le .h il y a :
et dans le projetViewController.m il y a :
PS: les smileys qui s inscrivent à 3 endroit dans le code sont en réalité un deux-points et une parenthèse : ( mais le générateur les interprète comme des smileys. Je n ai pas trouvé comment les afficher correctement.
Merci d avance.
Je voudrais lancer une video après avoir cliqué sur un bouton.
J ai bidouillé un petit code mais ça ne marche pas. En fait c est un code qui se situait dans le - (void)loadView et la ça marchait très bien. Au lancement de la vue la video jouait direct. J ai copié le code et créé un bouton IBAction et la ça ne marche pas.
Quelqu un pourrait il me dire ce qu il faut faire pour arranger ça ?
Je cré une baseViewApplication et dans le .h il y a :
Bloc de code:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface moviePlayerViewController : UIViewController {
MPMoviePlayerController *mp;
}
- (IBAction) touchImage;
@property(nonatomic, retain) MPMoviePlayerController *mp;
@end
Pourriez vous me dire comment faire en sorte pour que ça marche ?#import "moviePlayerViewController.h"
@implementation moviePlayerViewController
@synthesize mp;
- (IBAction) touchImage {
NSString *movpath = [[NSBundle mainBundle] pathForResource"nature" ofType"mov"];
MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
self.view = mpviewController.view;
self.mp = [mpviewController moviePlayer];
[mp prepareToPlay];
[mp play];
}
- (void) moviePlayBackDidFinish: (NSNotification *) notification
{
[mp stop];
// [mp autorelease];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)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)shouldAutorotateToInterfaceOrientationUIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation = YES);
}
- (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];
[mp dealloc];
}
@end
PS: les smileys qui s inscrivent à 3 endroit dans le code sont en réalité un deux-points et une parenthèse : ( mais le générateur les interprète comme des smileys. Je n ai pas trouvé comment les afficher correctement.
Merci d avance.