CPI_Player_Callbacks.c
资源名称:VC++视频传输.rar [点击查看]
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:4k
源码类别:
VC书籍
开发平台:
Visual C++
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_Player.h"
- #include "CPI_Playlist.h"
- #include "CPI_PlaylistItem.h"
- #define CP_SYNCCOOKIE_DESTROY 301
- void CPI_Player_cb_OnStreamInfo(CP_HPLAYER hPlayer, const CPs_FileInfo* pInfo)
- {
- globals.main_long_track_duration = pInfo->m_iFileLength_Secs;
- if(pInfo->m_iBitRate_Kbs)
- _itoa(pInfo->m_iBitRate_Kbs, globals.main_text_bitrate, 10);
- else
- globals.main_text_bitrate[0] = ' ';
- if(pInfo->m_iFreq_Hz)
- _itoa(pInfo->m_iFreq_Hz / 1000, globals.main_text_frequency, 10);
- else
- globals.main_text_frequency[0] = ' ';
- main_draw_bitrate(windows.wnd_main);
- main_draw_frequency(windows.wnd_main);
- }
- //
- void CPI_Player_cb_OnStreamOffset_Secs(CP_HPLAYER hPlayer, const int iTrackElapsedSeconds)
- {
- globals.main_int_track_total_seconds = iTrackElapsedSeconds;
- main_draw_time(windows.wnd_main);
- }
- //
- void CPI_Player_cb_OnStreamOffset_Range(CP_HPLAYER hPlayer, const int iTrackElapsed_Range)
- {
- globals.main_int_track_position = iTrackElapsed_Range;
- if(globals.m_bStreaming == TRUE)
- main_draw_vu_from_value(windows.wnd_main, PositionSlider, globals.m_iStreamingPortion);
- else
- main_draw_vu_from_value(windows.wnd_main, PositionSlider, globals.main_int_track_position);
- }
- //
- void CPI_Player_cb_OnPlayerState(CP_HPLAYER hPlayer, const CPe_PlayerState enPlayerState)
- {
- switch(enPlayerState)
- {
- case cppsEndOfStream:
- {
- CP_HPLAYLISTITEM hCurrent = CPL_GetActiveItem(globals.m_hPlaylist);
- if(options.repeat_playlist == FALSE
- && options.shuffle_play == FALSE
- && (hCurrent == NULL || CPLI_Next(hCurrent) == NULL) )
- {
- CPI_Player__BlockMessagesUntilEndOfStream(hPlayer);
- if(options.auto_exit_after_playing == TRUE)
- CPI_Player__SendSyncCookie(hPlayer, CP_SYNCCOOKIE_DESTROY);
- }
- else
- {
- if(options.seconds_delay_after_track > 0)
- SetTimer(windows.wnd_main, CPC_TIMERID_INTERTRACKDELAY, 2000 + (options.seconds_delay_after_track * 1000), NULL);
- else
- CPL_PlayItem(globals.m_hPlaylist, FALSE, pmNextItem);
- }
- }
- break;
- case cppsPlaying:
- case cppsPaused:
- globals.m_enPlayerState = enPlayerState;
- main_draw_controls_all(windows.wnd_main);
- break;
- case cppsStopped:
- globals.m_enPlayerState = enPlayerState;
- memset(globals.main_text_bitrate, 0, sizeof(globals.main_text_bitrate));
- memset(globals.main_text_frequency, 0, sizeof(globals.main_text_frequency));
- main_draw_bitrate(windows.wnd_main);
- main_draw_frequency(windows.wnd_main);
- globals.main_int_track_total_seconds = 0;
- main_draw_time(windows.wnd_main);
- globals.main_int_track_position = 0;
- main_draw_vu_from_value(windows.wnd_main, PositionSlider, globals.main_int_track_position);
- main_draw_controls_all(windows.wnd_main);
- break;
- }
- }
- //
- void CPI_Player_cb_OnSyncCookie(CP_HPLAYER hPlayer, const int iCookie)
- {
- if(iCookie == CP_SYNCCOOKIE_DESTROY)
- DestroyWindow(windows.wnd_main);
- }
- //
- void CPI_Player_cb_OnVolumeChange(CP_HPLAYER hPlayer, const int iNewVolume)
- {
- globals.m_iVolume = iNewVolume;
- main_draw_vu_from_value(windows.wnd_main, VolumeSlider, iNewVolume);
- }
- //
- void CPI_Player_cb_OnStreamStateChange(CP_HPLAYER hPlayer, const BOOL bStreaming, const int iBufferUsagePercent)
- {
- const int iRange = Skin.Object[PositionSlider].maxw ? Skin.Object[PositionSlider].h : Skin.Object[PositionSlider].w;
- globals.m_bStreaming = bStreaming;
- if(iRange)
- globals.m_iStreamingPortion = (iBufferUsagePercent * iRange) / 100;
- else
- globals.m_iStreamingPortion = 0;
- main_draw_vu_from_value(windows.wnd_main, PositionSlider, globals.m_iStreamingPortion);
- }
- //
- void CPI_Player_cb_OnEnumOutputDevice(CP_HPLAYER hPlayer, const char* pcDeviceName, const int iDeviceID)
- {
- int iNewDeviceIDX;
- iNewDeviceIDX = SendDlgItemMessage(windows.dlg_options, IDC_OUTPUT, CB_ADDSTRING, 0, (LPARAM)pcDeviceName);
- SendDlgItemMessage(windows.dlg_options, IDC_OUTPUT, CB_SETITEMDATA, iNewDeviceIDX - 1, MAKELPARAM(iDeviceID,iDeviceID));
- SendDlgItemMessage(windows.dlg_options, IDC_OUTPUT, CB_SETCURSEL, options.decoder_output_mode, 0);
- }