bool CSoundMgr::GetMusicPlayState (SMusicPlayState *retState) // GetMusicPlayState // // Returns the current play state. Returns FALSE if not playing { if (m_hMusic == NULL) { retState->bPlaying = false; retState->iLength = 0; retState->iPos = 0; retState->sFilename = NULL_STR; return false; } int iMode = MCIWndGetMode(m_hMusic, NULL, 0); retState->bPlaying = (iMode == MCI_MODE_PLAY); retState->bPaused = (iMode == MCI_MODE_PAUSE); retState->iLength = MCIWndGetLength(m_hMusic); retState->iPos = MCIWndGetPosition(m_hMusic); char *pDest = retState->sFilename.GetWritePointer(MAX_PATH); MCIWndGetFileName(m_hMusic, pDest, retState->sFilename.GetLength()); retState->sFilename.Truncate(lstrlen(pDest)); return retState->bPlaying; }
/** * Timer callback used to check about end of media (except JTS type) */ static void CALLBACK audio_timer_callback(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { audio_handle* pHandle = (audio_handle*)dwUser; if (pHandle->hWnd) { if (-1 == pHandle->duration) { pHandle->duration = MCIWndGetLength(pHandle->hWnd); JAVA_DEBUG_PRINT1("[jc_media] audio_timer_callback %d\n", pHandle->duration); } pHandle->offset = MCIWndGetPosition(pHandle->hWnd); pHandle->curTime = pHandle->offset; /* Is end of media reached? */ if (pHandle->offset >= pHandle->duration) { /* Post EOM event to Java and kill player timer */ pHandle->timerId = 0; pHandle->offset = 0; timeKillEvent(uID); JAVA_DEBUG_PRINT1("[jc_media] javanotify_on_media_notification %d\n", pHandle->playerId); javanotify_on_media_notification(JAVACALL_EVENT_MEDIA_END_OF_MEDIA, pHandle->playerId, (void*)pHandle->duration); } } }
void MCIOBJ::work(void) { // InvalidateRect(displayWnd,NULL,FALSE); if (GLOBAL.fly) return; if (!m_video) return; if (MCIWndGetPosition(m_video)==MCIWndGetLength(m_video)) playing=FALSE; if ((play!=INVALID_VALUE) && (m_video) && (!playing)) { if ((!play_once)||(resetted)) { MCIWndPlay(m_video); playing = TRUE; } resetted=FALSE; } if (play==INVALID_VALUE) { resetted=TRUE; if ((m_video) && (playing)) { MCIWndStop(m_video); playing=FALSE; } } acttime=TIMING.acttime-prevtime; if (((float)acttime/(float)TIMING.pcfreq*1000)>(float)upd_speed) { prevtime=TIMING.acttime; if (actspeed!=speed) { actspeed=speed; MCIWndSetSpeed(m_video, speed); } if (actvolume!=volume) { actvolume=volume; MCIWndSetVolume(m_video, volume); } if (step) { MCIWndStep(m_video,step); step=0;} if (pos_change) {MCIWndSeek(m_video,pos_center+pos_change); pos_change=0;} if (MCIWndGetPosition(m_video)==MCIWndGetLength(m_video)) { //MCIWndPlay(m_video); MCIWndSeek(m_video,1); } } }
static javacall_result audio_stop(javacall_handle handle){ audio_handle* pHandle = (audio_handle*)handle; audio_prepare_MCIWnd(pHandle); if (pHandle->hWnd) { /* Get stopped position for later use */ pHandle->offset = MCIWndGetPosition(pHandle->hWnd); if (pHandle->offset >= MCIWndGetLength(pHandle->hWnd)) { pHandle->offset = 0; } /* Kill player timer */ if (pHandle->timerId) { timeKillEvent(pHandle->timerId); pHandle->timerId = 0; } MCIWndStop(pHandle->hWnd); } return JAVACALL_OK; }
static javacall_result audio_start(javacall_handle handle){ audio_handle* pHandle = (audio_handle*)handle; if (JAVACALL_FALSE == pHandle->isForeground) { JAVA_DEBUG_PRINT("[jc_media] Audio fake start in background!\n"); return JAVACALL_OK; } /* Create MCI window by using temp file */ audio_prepare_MCIWnd(pHandle); JAVA_DEBUG_PRINT1("[jc_media] + javacall_media_start %s\n", pHandle->fileName); /* Seek to play position */ if (pHandle->offset) { MCIWndSeek(pHandle->hWnd, pHandle->offset); pHandle->curTime = pHandle->offset; } else { pHandle->curTime = 0; } /* Start play */ if (pHandle->hWnd && 0 == MCIWndPlay(pHandle->hWnd)) { JAVA_DEBUG_PRINT("[jc_media] - javacall_media_start OK\n"); pHandle->duration = MCIWndGetLength(pHandle->hWnd); javanotify_on_media_notification(JAVACALL_EVENT_MEDIA_DURATION_UPDATED, pHandle->playerId, (void*)pHandle->duration); pHandle->timerId = (UINT)timeSetEvent(TIMER_CALLBACK_DURATION, 100, audio_timer_callback,(DWORD)pHandle, TIME_PERIODIC); return JAVACALL_OK; } return JAVACALL_FAIL; }