Good way to discriminate between Mathematica/PlayerPro/CDFPlayer
The straightforward way to discriminate is to use $LicenseType
, (unfortunately undocumented and not even WolframLanguageData
knows about it). Deploying the following line as a CDF file and opening it in various environments provides the following results (thanks for Oleksandr's comment):
Dynamic@{$LicenseType, Developer`$ProtectedMode, CurrentValue["PluginEnabled"]}
(* Mathematica 8-10 *) {"Professional", False, False}
(* CDF Player *) {"Player", False, False}
(* Firefox w/ browser plugin *) {"Professional", True, True}
(* Player Pro *) {"Player Pro", False, False}
For more on $LicenseType
, see other thread.
As of version 10, one can also use $EvaluationEnvironment
, answering a different, but related question. It returns one of the followings:
"Session" local interactive session
"RemoteSession" remote interactive session
"CDF" standalone CDF
"Script" script run in batch mode
"Subkernel" parallel or grid subkernel
"WebEvaluation" direct URL evaluation
"WebLoad" evaluation when loading a webpage
"WebAPI" API called through an HTTP request
"WebForm" web form
"WebServer" web server plugin (e.g. JSP)
"CloudCDF" cloud CDF
"PlugInCDF" CDF web plugin
"Scheduled" scheduled task
"WolframLink" WolframLink call
Please feel free to add to the lists if you know other licenses/environments.
The following
MathLink`CallFrontEnd@FrontEnd`Value["$NotebookLicenseType"]
will distinguish "Player Pro" from just "Player", or Mathematica, which the other methods do not handle if you need to make such a distinction.
These are undocumented, but I doubt they will change much going forward... I think they are available in v9 or later, but I don't recall exactly when they were introduced...
FE`Evaluate@FEPrivate`PlayerQ[]
FE`Evaluate@FEPrivate`PlayerProQ[]
FEPrivate`PlayerQ[]
returns True when the document is running in CDF Player mode. FEPrivate`PlayerProQ[]
returns True when the document is an EnterpriseCDF or is running inside of an activated copy of CDF Player.
If you use them inside of a Dynamic
, you probably would not need to use the FE`Evaluate
wrapper.