1

私は MonoMac を使用していますが、cocoa と objc については十分に理解しています。

mp4 を返す Web サーバーからの URL があります。MonoMac アプリケーションで QuickTime を起動し、その URL の再生を開始したいと考えています。

私はこれらの方法を試しました:

Process.Start("/Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player", url);

しかし、URL がhttp://webhost/1/blah.mp4のようなものである場合、quicktime は「ドキュメント blah.mp4 を開けませんでした。ファイルが存在しません。ファイルが存在することを知っており、すべてが正しいです。私はこの方法を使用します:

var cfurl = MonoMac.CoreFoundataion.CFUrl.FromUrlString(url, null);
LSOpenCFURLRef(cfurl.Handle, (IntPtr)null);

ストリームが Safari で開かれ、QuickTime プラグインが再生を開始します。

NSWorkspace OpenUrls と OpenFile も試しました

NSWorkspace.SharedWorkspace.OpenUrls(new[]{NSUrl.FromString(url)},
                                     @"com.apple.quicktimeplayer", 
                                     NSWorkspaceLaunchOptions.Async,
                                     new NSAppleEventDescriptor(),
                                     new[]{""});

しかし、これはサファリで起動します

 NSWorkspace.SharedWorkspace.OpenFile(url, "QuickTimePlayer");

しかし、これは何もしません。

だから私はNSTaskを試します

MonoMac.Foundation.NSTask.LaunchFromPath("/Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player",
                                         new string[] {url});

しかし、これは上記の私の最初の試みと同じ「...見つかりませんでした...」を与えます。

最後に、QuickTime Player を起動して開く URL を使用し、その URL をテキスト ボックスに貼り付けて [開く] をクリックすると、ストリームはエラーなしで再生されます。

ココア アプリから QuickTime Player に URL を送信するにはどうすればよいですか?

4

1 に答える 1

2

URL がリモート URL であることを考慮すると、Cocoa アプリケーションで Scripting Bridge を使用して、QuickTime Player にリモート URL を開くように指示できます。

id qtApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.QuickTimePlayerX"];
[qtApp activate];
if ([qtApp isRunning]) {
    // note that the parameter to openURL: must be the string representation of a URL
    [qtApp openURL:@"http://movies.apple.com/media/us/ipad/2011/tours/apple-ipad2-feature-us-20110302_r848-9cie.mov?width=848&height=480"];
}

Scripting Bridge フレームワークをアプリケーションにリンクする必要があります。

于 2011-04-07T01:59:44.860 に答える