I am trying to deploy a CDF file with a small animation that does the following: when the button is pressed, it plays a sound and displays a spectrogram ; while the sound plays, a red progress line moves across the spectrogram to indicate where we are at.
As you can see in the following screen capture, the code (see below) works fine within Mathematica and in the exported CDF file as long as it’s played by Mathematica. However, when played within the Free CDF Player, I get the correct sound but not the progress line and the graphic is red, which indicates a problem. Sadly, it does not generate any error message.
What am I doing wrong ?
Here is the code:
SetDirectory[NotebookDirectory[]];
CDFDeploy["test.cdf", DynamicModule[{sound, astream, bg, dim},
Column[{Dynamic@Show[ImageCompose[bg,
Graphics[{Red,InfiniteLine[{(.2 + QuantityMagnitude@astream["Position"])/QuantityMagnitude@Duration[sound]*dim[[1, 2]] , 0}, {0,1}]},
PlotRange -> dim]], ImageSize -> {Automatic, 200}],
Button["Play", AudioPlay[astream]]}],
Initialization :> (
sound = ExampleData[{"Audio", "PianoScale"}];
astream = AudioStream[sound];
bg = Rasterize[Grid[{
{AudioPlot[sound, ImageSize -> 500, FrameTicks -> None]},
{Spectrogram[sound, ImageSize -> 500, FrameTicks -> None]}
}]];
dim = Transpose[{{0, 0}, ImageDimensions[bg]}];
)]];
I tried using SaveDefinitions
instead of Initialization
; I tried exporting directly to a CDF (with the menus) instead of CDFDeploy
. But the problems is always the same. Thanks !
PS. The motivation for this question : the file is to be deployed to a large community of students that only have access to the Free CDF Player but not to Mathematica, nor the Pro Player.
DynamicModule
, there are three errorsShow::gtype: ImageCompose is not a type of graphics.
The specified setting for the option GraphicsBoxOptions, PlotRange cannot be used.
ConicHullRegion[{Part[$CellContext
dim$$, 1, 2] (0.2 + QuantityMagnitude[$CellContextastream$$["Position"]])/QuantityMagnitude[Duration[$CellContext
sound$$]], 0}, {{0, 1}}] is not a valid ConicHullRegion specification.` $\endgroup$ConicHullRegion
at least not that I know of so I am curious how can it be quoted in your error message ? I just checked with FullForm:bg
is anImage[]
; I tried changingbg=Rasterize[...]
tobg=Rasterize[...,"Graphics"]
so both arguments ofShow
areGraphics[]
but it does not solve the issue. $\endgroup$