Getting the frame from movie in material [SOLVED]

I have a material with a movie loaded in the Color channel. When I apply the material to an object and set the Editor->Animate Preview option on, scrubbing the timeline, I see the movie playing in the object surface.
However, when I try to get the bitmap from the material, using this python code, it always gets me the first frame, no matter where I have the play-head:

import c4d
#Welcome to the world of Python
def main() :
mat=op[c4d.ID_USERDATA,1]
# is there anything in the Link user data?
if mat==None: return
# is it a Material?
if mat.GetType()!=5703: return
color_ch=mat[c4d.MATERIAL_USE_COLOR]
# is the Color channel turned on?
if color_ch==0: return
texture=mat[c4d.MATERIAL_COLOR_SHADER]
# is there anything in the Texture slot?
if texture==None: return
# is it a bitmap/movie?
if texture.GetType()!=5833: return
# render the bitmap to the Picture Viewer
irs = c4d.modules.render.InitRenderStruct()
if texture.InitRender(irs)==c4d.INITRENDERRESULT_OK:
bitmap = texture.GetBitmap()
texture.FreeRender()
if bitmap is not None:
c4d.bitmaps.ShowBitmap(bitmap)

Yes, I do get a "RuntimeError: illegal operation, invalid cross-thread call" error in the last line of code but, even so, I get an image in the Picture Viewer and it is ALWAYS the first frame of the movie.

How can I get the correctly calculated frame, according to the parameters set in the Animation tab inside the material channel?

Thank you. I did found that thread.
But I will have to calculate the frame by myself, right?
I was expecting that, once we had a material with a movie or image sequence loaded in the Color channel and we had all the parameters of the animation set (by pressing Calculate for an image sequence, for example), there was a way to get the calculated frame automatically.