How to launch QuickTime from a Mac App

RobertDalyRobertDaly USMember ✭✭

Hi Anyone!

I have been trying to launch QuickTime from my app and I am able to launch it successfully. However, I want it to play an audio file and I have not been having any success with it.
I found an objective-c example below and am able to make use of some of it (namely the first two lines - see my code below)

id qtApp = [SBApplication];
[qtApp activate];
if ([qtApp isRunning]) {
// note that the parameter to openURL: must be the string representation of a URL
[qtApp openURL:@""];

My Code:
SBApplication app; // Reference to an app

            app = SBApplication.FromBundleIdentifier(""); // Get it
            app.Activate(); // And activate it

This code launches successfully QuickTime, but I don't know how to use the openURL: to have QuickTime play the audio file. I made sure it runs properly outside of my app (directly with QuickTime) and I have tried a number of things to get it to work. Shown below is what I have tried:

            NSUrl url = new NSUrl(lblImagePath.StringValue);

            Selector sel = new Selector("openURL:");

            SBApplication app; 

            app = SBApplication.FromBundleIdentifier("");
            if(app.IsRunning) {


This results in a message from QuickTime: The movie “sample_both.mp3” can’t be opened because the file is not in a format that QuickTime Player understands. The file may be damaged or may not be a movie file...

If anyone can assist, I would be most grateful!



  • DavidLilleyDavidLilley USMember ✭✭✭

    It seems a complicated way to go, Perhaps the way to go is..

    NSWorkspace.SharedWorkspace.OpenUrl(aURL); (opens a web browsers)
    NSWorkspace.SharedWorkspace.OpenFile(sPath, sAppName);

  • RobertDalyRobertDaly USMember ✭✭

    Hi David,

    Many thanks! I just discovered the same thing last night at the following link: (in the Raw output shown below). The only one that worked was the NSWorkspace.SharedWorkspace.OpenFile(url, "QuickTimePlayer"); with modification - "QuickTimePlayer" should be "QuickTime" and the url has to be a string, not a NSUrl.
    Additionally, the qtApp area below (SBApplication does not have the openURL method in Xamarin. My code is simply as follows:


    And this works fine!

    Thanks again!


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

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

    new NSAppleEventDescriptor(),

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

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

    id qtApp = [SBApplication];
    [qtApp activate];
    if ([qtApp isRunning]) {
    // note that the parameter to openURL: must be the string representation of a URL
    [qtApp openURL:@""];


Sign In or Register to comment.