| Home 目次>ApplicationKit>NSMovie | |
initWithMovie:
ムービーのポインタからNSMovieを初期化して返します
-(id) initWithMovie:(void *)movie
【返り値】 | |
| id | ムービー |
| 【パラメータ】 | |
| movie | ムービー |
【解説】
ムービーのポインタからNSMovieを初期化して返します。
10.5以降はQTKitを使ってください。
【例文】
#import "MyObject.h"
@implementation MyObject
- (IBAction)act:(id)sender;//アクション
{
NSLog([[NSMovie movieUnfilteredFileTypes] description]);
}
- (IBAction)setMov:(id)sender//ムービーをセット
{
//開けるファイル拡張子の配列
NSArray *imgTypes = [NSMovie movieUnfilteredFileTypes];
//OpenPanelを作る
NSOpenPanel *opPanel = [ NSOpenPanel openPanel ];
//OpenPanelの結果のボタン番号
int opRet;
//ムービーのURL
NSURL *movUrl ;
//ムービー
NSMovie *theMovie;
void *mPointer;
NSMovie *qtmov;
//OpenPanelでファイル選択
opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
file : @"Movies" //どのどのファイルを選択しておくか
types : imgTypes ];//選べるファイルタイプ
if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら
//NSImageを作ってファイルから読み込む
movUrl = [NSURL fileURLWithPath:[ opPanel filename ]];
theMovie = [[NSMovie alloc] initWithURL:movUrl byReference:YES];
[myOutlet setMovie:theMovie];
mPointer = [[myOutlet movie] QTMovie];
qtmov = [[[NSMovie alloc] initWithMovie:mPointer] autorelease];
[myOutlet setMovie:qtmov];
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSMovie | 修正日2006.12.26 |