Here’s a nice(but old) tutorial on how to do it.
Another solution is to run the script The Loopmaker on your layer. The script will loop any amount of selected layers from the furthest in-point and the last out-point by pre-composing and doing a dissolving loop. It will then apply an expression to the looped comp so that it can be stretched infinitely from either the in or the out-point.
Johnny Cuevas, Editor
Thinkck.com
“I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.”
—THOMAS EDISON on inventing the light bulb.