⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interface.c

📁 uclinux下mplayer的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    }    while(GetMessage(&msg, NULL, 0, 0))    {        TranslateMessage(&msg);        DispatchMessage(&msg);    }    fprintf(stderr, "[GUI] GUI thread terminated.\n");    fflush(stderr);    return 0;}void guiInit(void){    memset(&guiIntfStruct, 0, sizeof(guiIntfStruct));    /* Create The gui thread */    if (!mygui)    {        hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId);        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId);    }    /* Wait until the gui is created */    while(!mygui) Sleep(100);    mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n");}void guiDone(void){    if(mygui)    {        fprintf(stderr, "[GUI] Closed by main mplayer window\n");        fflush(stderr);        PostThreadMessage(threadId, WM_QUIT, 0, 0);        WaitForSingleObject(hThread, INFINITE);        CloseHandle(hThread);        mygui->uninit(mygui);        free(mygui);        mygui = NULL;    }    /* Remove tray icon */    Shell_NotifyIcon(NIM_DELETE, &nid);    cfg_write();}/* this function gets called by mplayer to update the gui */int guiGetEvent(int type, char *arg){    stream_t *stream = (stream_t *) arg;#ifdef USE_DVDREAD    dvd_priv_t *dvdp = (dvd_priv_t *) arg;#endif    if(!mygui || !mygui->skin) return 0;    if(guiIntfStruct.mpcontext)    {        audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext);        video_out = mpctx_get_video_out(guiIntfStruct.mpcontext);        mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);        playtree = mpctx_get_playtree_iter(guiIntfStruct.mpcontext);    }    switch (type)    {        case guiSetFileFormat:            guiIntfStruct.FileFormat = (int) arg;            break;        case guiSetParameters:        {            guiGetEvent(guiSetDefaults, NULL);            guiIntfStruct.DiskChanged = 0;            guiIntfStruct.FilenameChanged = 0;            guiIntfStruct.NewPlay = 0;            switch(guiIntfStruct.StreamType)            {                case STREAMTYPE_PLAYLIST:                    break;#ifdef USE_DVDREAD                case STREAMTYPE_DVD:                {                    char tmp[512];                    dvd_title = guiIntfStruct.DVD.current_title;                    dvd_chapter = guiIntfStruct.DVD.current_chapter;                    dvd_angle = guiIntfStruct.DVD.current_angle;                    sprintf(tmp,"dvd://%d", guiIntfStruct.Title);                    guiSetFilename(guiIntfStruct.Filename, tmp);                    break;                }#endif            }            if(guiIntfStruct.Filename)                filename = strdup(guiIntfStruct.Filename);            else if(filename)                strcpy(guiIntfStruct.Filename, filename);            break;        }        case guiSetAudioOnly:        {            guiIntfStruct.AudioOnly = (int) arg;            if(IsWindowVisible(mygui->subwindow))                ShowWindow(mygui->subwindow, SW_HIDE);            break;        }        case guiSetContext:            guiIntfStruct.mpcontext = (void *) arg;            break;        case guiSetDemuxer:            guiIntfStruct.demuxer = (void *) arg;            break;        case guiSetValues:        {            guiIntfStruct.sh_video = arg;            if (arg)            {                sh_video_t *sh = (sh_video_t *)arg;                codecname = sh->codec->name;                guiIntfStruct.FPS = sh->fps;                /* we have video, show the subwindow */                if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow))                    ShowWindow(mygui->subwindow, SW_SHOWNORMAL);                if(WinID == -1)                    update_subwindow();            }            break;        }        case guiSetShVideo:        {            guiIntfStruct.MovieWidth = vo_dwidth;            guiIntfStruct.MovieHeight = vo_dheight;            sub_aspect = (float)guiIntfStruct.MovieWidth/guiIntfStruct.MovieHeight;            if(WinID != -1)               update_subwindow();            break;        }        case guiSetStream:        {            guiIntfStruct.StreamType = stream->type;            switch(stream->type)            {#ifdef USE_DVDREAD                case STREAMTYPE_DVD:                    guiGetEvent(guiSetDVD, (char *) stream->priv);                    break;#endif            }            break;        }#ifdef USE_DVDREAD        case guiSetDVD:        {            guiIntfStruct.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts;            guiIntfStruct.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts;            guiIntfStruct.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles;            guiIntfStruct.DVD.nr_of_audio_channels = dvdp->nr_of_channels;            memcpy(guiIntfStruct.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams));            guiIntfStruct.DVD.nr_of_subtitles = dvdp->nr_of_subtitles;            memcpy(guiIntfStruct.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles));            guiIntfStruct.DVD.current_title = dvd_title + 1;            guiIntfStruct.DVD.current_chapter = dvd_chapter + 1;            guiIntfStruct.DVD.current_angle = dvd_angle + 1;            guiIntfStruct.Track = dvd_title + 1;            break;        }#endif        case guiReDraw:            mygui->updatedisplay(mygui, mygui->mainwindow);            break;        case guiSetAfilter:            guiIntfStruct.afilter = (void *) arg;            break;        case guiCEvent:        {            guiIntfStruct.Playing = (int) arg;            switch (guiIntfStruct.Playing)            {                case guiSetPlay:                {                    guiIntfStruct.Playing = 1;                    break;                }                case guiSetStop:                {                    guiIntfStruct.Playing = 0;                    if(movie_aspect >= 0)                        movie_aspect = -1;                    update_subwindow();                    break;                }                case guiSetPause:                    guiIntfStruct.Playing = 2;                    break;            }            break;        }        case guiIEvent:        {            mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg);            /* MPlayer asks us to quit */            switch((int) arg)            {                case MP_CMD_GUI_FULLSCREEN:                    mplFullScreen();                    break;                case MP_CMD_QUIT:                {                    mygui->uninit(mygui);                    free(mygui);                    mygui = NULL;                    exit_player("Done");                    return 0;                }                case MP_CMD_GUI_STOP:                    guiGetEvent(guiCEvent, (void *) guiSetStop);                    break;                case MP_CMD_GUI_PLAY:                    guiGetEvent(guiCEvent, (void *) guiSetPlay);                    break;                case MP_CMD_GUI_SKINBROWSER:                    if(fullscreen) guiSetEvent(evFullScreen);                    PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_SKINBROWSER, 0);                    break;                case MP_CMD_GUI_PLAYLIST:                    if(fullscreen) guiSetEvent(evFullScreen);                    PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PLAYLIST, 0);                    break;                case MP_CMD_GUI_PREFERENCES:                    if(fullscreen) guiSetEvent(evFullScreen);                    PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PREFS, 0);                    break;                case MP_CMD_GUI_LOADFILE:                    if(fullscreen) guiSetEvent(evFullScreen);                    PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDFILE_OPEN, 0);                    break;                case MP_CMD_GUI_LOADSUBTITLE:                    if(fullscreen) guiSetEvent(evFullScreen);                    PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDSUBTITLE_OPEN, 0);                    break;                default:                    break;            }            break;        }        case guiSetFileName:            if (arg) guiIntfStruct.Filename = (char *) arg;            break;        case guiSetDefaults:        {            audio_id = -1;            video_id = -1;            dvdsub_id = -1;            vobsub_id = -1;            stream_cache_size = -1;            autosync = 0;            vcd_track = 0;            dvd_title = 0;            force_fps = 0;            if(!mygui->playlist->tracks) return 0;            filename = guiIntfStruct.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename;            guiIntfStruct.Track = mygui->playlist->current + 1;            if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm");            if(gtkAOExtraStereo)            {                char *name = malloc(12 + 20 + 1);                snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul);                name[12 + 20] = 0;                greplace(&af_cfg.list, "extrastereo", name);                free(name);            }            if(gtkCacheOn) stream_cache_size = gtkCacheSize;            if(gtkAutoSyncOn) autosync = gtkAutoSync;            break;        }        case guiSetVolume:        {            if(audio_out)            {                /* Some audio_out drivers do not support balance e.g. dsound */                /* FIXME this algo is not correct */                float l, r;                mixer_getvolume(mixer, &l, &r);                guiIntfStruct.Volume = (r > l ? r : l); /* max(r,l) */                if (r != l)                    guiIntfStruct.Balance = ((r-l) + 100.0f) * 0.5f;                else                    guiIntfStruct.Balance = 50.0f;            }            break;        }        default:            mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", type);    }    return 0;}/* This function adds/inserts one file into the gui playlist */int import_file_into_gui(char *pathname, int insert){    char filename[MAX_PATH];    char *filepart = filename;    if (strstr(pathname, "://"))    {        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname);        mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0);        return 1;    }    if (GetFullPathName(pathname, MAX_PATH, filename, &filepart))    {        if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY))        {            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename);            mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0);            return 1;        }        else            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename);    }    return 0;}/*  This function imports the initial playtree (based on cmd-line files) into the gui playlist    by either:    - overwriting gui pl (enqueue=0) */int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue){    play_tree_iter_t *my_pt_iter = NULL;    int result = 0;    if(!mygui) guiInit();    if((my_pt_iter = pt_iter_create(&my_playtree, config)))    {        while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)        {            if (parse_filename(filename, my_playtree, config, 0))                result = 1;            else if (import_file_into_gui(filename, 0)) /* Add it to end of list */                result = 1;        }    }    mplGotoTheNext = 1;    if (result)    {        mygui->playlist->current = 0;        filename = mygui->playlist->tracks[0]->filename;    }    return result;}/* This function imports and inserts an playtree, that is created "on the fly", for example by   parsing some MOV-Reference-File; or by loading an playlist with "File Open"   The file which contained the playlist is thereby replaced with it's contents. */int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config){    play_tree_iter_t *my_pt_iter = NULL;    int result = 0;    if((my_pt_iter = pt_iter_create(&my_playtree, config)))    {        while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)            if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */                result = 1;        pt_iter_destroy(&my_pt_iter);    }    filename = NULL;    return result;}inline void gtkMessageBox(int type, const char *str){    if (type & GTK_MB_FATAL)        MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR);    fprintf(stderr, "[GUI] MessageBox: %s\n", str);    fflush(stderr);}void guiMessageBox(int level, char *str){    switch(level)    {        case MSGL_FATAL:            gtkMessageBox(GTK_MB_FATAL | GTK_MB_SIMPLE, str);            break;        case MSGL_ERR:            gtkMessageBox(GTK_MB_ERROR | GTK_MB_SIMPLE, str);            break;    }}static int update_subwindow(void){    int x,y;    RECT rd;    WINDOWPOS wp;    if(!sub_window)    {        WinID = -1; // so far only directx supports WinID in windows        if(IsWindowVisible(mygui->subwindow) && guiIntfStruct.sh_video && guiIntfStruct.Playing)        {            ShowWindow(mygui->subwindow, SW_HIDE);            return 0;        }        else if(guiIntfStruct.AudioOnly)            return 0;        else ShowWindow(mygui->subwindow, SW_SHOW);    }    /* we've come out of fullscreen at the end of file */    if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && !guiIntfStruct.AudioOnly)        ShowWindow(mygui->subwindow, SW_SHOWNORMAL);    /* get our current window coordinates */    GetWindowRect(mygui->subwindow, &rd);    x = rd.left;    y = rd.top;    /* restore sub window position when coming out of fullscreen */    if(x <= 0) x = old_rect.left;    if(y <= 0) y = old_rect.top;    if(!guiIntfStruct.Playing)    {        window *desc = NULL;        int i;        for (i=0; i<mygui->skin->windowcount; i++)            if(mygui->skin->windows[i]->type == wiSub)                desc = mygui->skin->windows[i];        rd.right = rd.left+desc->base->bitmap[0]->width;        rd.bottom = rd.top+desc->base->bitmap[0]->height;        sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top);    }    else    {        rd.right = rd.left+guiIntfStruct.MovieWidth;        rd.bottom = rd.top+guiIntfStruct.MovieHeight;        if (movie_aspect > 0.0)       // forced aspect from the cmdline            sub_aspect = movie_aspect;    }    AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0);    SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER);    wp.hwnd = mygui->subwindow;    wp.x = rd.left;    wp.y = rd.top;    wp.cx = rd.right-rd.left;    wp.cy = rd.bottom-rd.top;    wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW;    /* erase the bitmap image if there's video */    if(guiIntfStruct.Playing != 0 && guiIntfStruct.sh_video)        SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0);    /* reset the window aspect */    SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);    return 0;}void guiEventHandling(void) {}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -