Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
QT 7.1.3 Flash enable fix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

QT 7.1.3 Flash enable fix



Okay, I've done some sniffing around in the QuickTime Preferences file, doing some before and after comparisons, and have come up some solutions to the 7.1.3 disabling Flash tracks by default.

This may not work in future releases of QT, but the same could be said of our apps that previously relied on Flash anyway. Use it at your own risk. The code checks the appropriate atoms using the QuickTime Preference functions. It works on PowerPC and Intel Macs, but interestingly enough QT stores the structure in native byte order which might be considered a bug in QT.

I'm not sure whether Flash has always been optional in QT (but enabled by default) or whether it only became optional with this update. You'll want to first do the appropriate gestaltQuickTimeVersion checks (eg. >= 0x07138000) before using these functions.

There are a couple of ways to use the functions. You could just use IsFlashEnabled() and present an meaningful error to the user, or you could change the setting yourself with EnableFlash() as well.

The catch is that these routines need to be called after EnterMovies (), but once EnterMovies() has been called at least once, the app will not notice the changes and Flash will still be disabled for that run.

This means you could auto-relaunch your app (only if EnableFlash() is successful otherwise show an alert). It will normally only ever have to do this once.

Or you could synchronously launch a tiny command-line tool that you store inside your bundle before you call EnterMovies(), and test EnterMovies() + IsFlashEnabled() after it returns, showing an error alert if it failed. The disadvantage of the second approach is that you cannot test (other than the QT version) beforehand, so you must run the tool every time. A little ugly, but in practice, any delay is probably negligible. The tool only needed to link to the QuickTime framework, and was basically: EnterMovies(); if (!IsFlashEnabled()) EnableFlash();

I've tested both, but ended up using the relaunching method.

Enjoy,
Scott.

enum {
    MediaEnablePref = 'scmh',
    MediaEnableType = 'xmpt'
};

enum {
    AppleMediaOwner = 'appl'
};

typedef struct QTEnableRec {
    OSType          media;
    OSType          owner;
} QTMediaEnable;

Boolean IsFlashEnabled(void)
{
    Boolean                 enabled = false;
    QTAtomContainer         prefs;
    QTAtom                  atom;
    SInt32                  size;
    QTMediaEnable           *data;

if (GetQuickTimePreference(MediaEnablePref, &prefs) == noErr && prefs) {
atom = QTFindChildByIndex(prefs, kParentAtomIsContainer, MediaEnablePref, 1, NULL);
if (atom) {
atom = QTFindChildByIndex(prefs, atom, MediaEnableType, 1, NULL);
if (atom) {
QTLockContainer(prefs);
if (QTGetAtomDataPtr(prefs, atom, &size, (Ptr *) &data) == noErr) {
if (size == sizeof(QTMediaEnable) && data->media == FlashMediaType && data->owner == AppleMediaOwner)
enabled = true;
}
QTUnlockContainer(prefs);
}
}
QTDisposeAtomContainer(prefs);
}
return enabled;
}


Boolean EnableFlash(void)
{
    QTAtomContainer         prefs;
    QTAtom                  atom;
    QTMediaEnable           data;
    Boolean                 enabled = false;

if (QTNewAtomContainer(&prefs) == noErr && prefs) {
if (QTInsertChild(prefs, kParentAtomIsContainer, MediaEnablePref, 0, 1, 0, NULL, &atom) == noErr) {
data.media = FlashMediaType;
data.owner = AppleMediaOwner;
if (QTInsertChild(prefs, atom, MediaEnableType, 0, 1, sizeof(QTMediaEnable), &data, &atom) == noErr)
if (SetQuickTimePreference(MediaEnablePref, prefs) == noErr)
enabled = true;
}
QTDisposeAtomContainer(prefs);
}
return enabled && IsFlashEnabled();
}


--
Scott Kevill
GameRanger Technologies
http://www.GameRanger.com
multiplayer online gaming services

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.