Esempio n. 1
0
static PyObject*
movie_get_length (PyObject* self)
{
    SMPEG* movie;
    SMPEG_Info info;

    if (!SDL_WasInit (SDL_INIT_VIDEO))
        return RAISE (PyExc_SDLError,
                      "cannot convert without pygame.display initialized");

    movie = PyMovie_AsSMPEG (self);

    Py_BEGIN_ALLOW_THREADS;
    SMPEG_getinfo (movie, &info);
    Py_END_ALLOW_THREADS;
    return PyFloat_FromDouble (info.total_time);
}
Esempio n. 2
0
/* The same as above except for file descriptors */
SMPEG* SMPEG_new_descr(int file, SMPEG_Info* info, int sdl_audio)
{
    SMPEG *mpeg;

    if (!sanityCheckByteorder())
        return(NULL);

    /* Create a new SMPEG object! */
    mpeg = new SMPEG;
    mpeg->obj = new MPEG(file, sdl_audio ? true : false);

    /* Find out the details of the stream, if requested */
    SMPEG_getinfo(mpeg, info);

    /* We're done! */
    return(mpeg);
}
Esempio n. 3
0
static PyObject*
movie_render_frame (PyObject* self, PyObject* args)
{
    SMPEG* movie = PyMovie_AsSMPEG (self);
    SMPEG_Info info;
    int framenum;

    if (!SDL_WasInit (SDL_INIT_VIDEO))
        return RAISE (PyExc_SDLError,
                      "cannot convert without pygame.display initialized");

    if (!PyArg_ParseTuple (args, "i", &framenum))
        return NULL;
    Py_BEGIN_ALLOW_THREADS;
    SMPEG_renderFrame (movie, framenum);
    SMPEG_getinfo (movie, &info);
    Py_END_ALLOW_THREADS;
    return PyInt_FromLong (info.current_frame);
}
Esempio n. 4
0
static PyObject*
movie_set_display (PyObject* self, PyObject* args)
{
    SMPEG* movie = PyMovie_AsSMPEG (self);
    PyObject* surfobj, *posobj=NULL;
    GAME_Rect *rect, temp;
    int x=0, y=0;
    if (!PyArg_ParseTuple (args, "O|O", &surfobj, &posobj))
        return NULL;


    if (!SDL_WasInit (SDL_INIT_VIDEO))
        return RAISE (PyExc_SDLError,
                      "cannot convert without pygame.display initialized");


    Py_XDECREF (((PyMovieObject*) self)->surftarget);
    ((PyMovieObject*) self)->surftarget = NULL;

    if (PySurface_Check (surfobj))
    {
        SMPEG_Info info;
        SDL_Surface* surf;

        if (posobj == NULL)
        {
            Py_BEGIN_ALLOW_THREADS;
            SMPEG_getinfo (movie, &info);
            SMPEG_scaleXY (movie, info.width, info.height);
            Py_END_ALLOW_THREADS;
            x = y = 0;
        }
        else if (TwoIntsFromObj (posobj, &x, &y))
        {
            Py_BEGIN_ALLOW_THREADS;
            SMPEG_getinfo (movie, &info);
            SMPEG_scaleXY (movie, info.width, info.height);
            Py_END_ALLOW_THREADS;
        }
        else if ((rect = GameRect_FromObject (posobj, &temp)))
        {
            x = rect->x;
            y = rect->y;
            Py_BEGIN_ALLOW_THREADS;
            SMPEG_scaleXY (movie, rect->w, rect->h);
            Py_END_ALLOW_THREADS;
        }
        else
            return RAISE (PyExc_TypeError, "Invalid position argument");

        surf = PySurface_AsSurface (surfobj);

        Py_BEGIN_ALLOW_THREADS;
        SMPEG_getinfo (movie, &info);
        SMPEG_enablevideo (movie, 1);
        SMPEG_setdisplay (movie, surf, NULL, NULL);
        SMPEG_move (movie, x, y);
        Py_END_ALLOW_THREADS;
    }
    else
    {
        Py_BEGIN_ALLOW_THREADS;
        SMPEG_enablevideo (movie, 0);
        Py_END_ALLOW_THREADS;
        if (surfobj != Py_None)
            return RAISE (PyExc_TypeError, "destination must be a Surface");
    }

    Py_RETURN_NONE;
}
// Return the current info for the movie
SMPEG_Info CSmpeg::GetInfo()
{
	SMPEG_getinfo( movie, &movieInfo );
	return movieInfo;
}