Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is a real newbie question, so apologies in advance for may seem a very dumb question ... I'm trying to understand the various ways in which information can be retained in a notebook between sessions, using DynamicModule[] etc. Understanding how a good MMA user would solve the following simple task would be really helpful:

Say I want to load a video file and then create a simple slider to scroll through the frames. This works:

frames = Import["myvideofile.avi", {"Frames", All}]; 
Manipulate[frames[[f]], {f, 1, Length[frames],1}]

But, say I want to remember which frame the slider was left at between Mathematica sessions, how would I do that elegantly? If I re-open the code above, there's an error because 'frames' isn't defined until the video is imported.

In other words, upon re-opening the notebook, the first thing I'd like to happen is for 'frames' to be imported. I'm speculating that I need DynamicModule, with Initialization but have tried many different ways and can't get it to work.

share|improve this question
Check SaveDefinitions -> True option of Manipulate and as well as the Initialization possibility. –  PlatoManiac Sep 12 '12 at 14:07
You may also use simply ListAnimate[frames]which should remember its content across session. Re-using those will be more tricky though. –  Yves Klett Sep 12 '12 at 15:21

1 Answer 1

up vote 4 down vote accepted

I guess the following will do what you want

Manipulate[frames[[f]], {f, 1, Length[frames], 1},SaveDefinitions -> True]

and this is faster in this case than importing the frames through Initialization option of Manipulate.

enter image description here

You can see while opening the notebook Slider remains in the same place as it was when the notebook was closed for the last time. The second version involving Initialization also does the job you want but it takes much time to load in the first place. This happens as Initialization needs first to import your data. In such time consuming cases we often need to override the initialization time out using SynchronousInitialization -> False.

share|improve this answer
Thanks, that's exactly it. –  Cuboid Sep 12 '12 at 14:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.