bool CSoundMgr::PlayMusic (const CString &sFilename, int iPos, CString *retsError) // PlayMusic // // Starts playing the given MP3 file { try { if (m_hMusic == NULL) return false; // Figure out our current state SMusicPlayState State; GetMusicPlayState(&State); // If we're not already playing this file, open it if (!strEquals(sFilename, State.sFilename)) { // Stop playing first if (State.bPlaying || State.bPaused) MCIWndStop(m_hMusic); // Open new file if (MCIWndOpen(m_hMusic, sFilename.GetASCIIZPointer(), MCI_OPEN_SHAREABLE) != 0) { if (retsError) { char *pDest = retsError->GetWritePointer(1024); MCIWndGetError(m_hMusic, pDest, retsError->GetLength()); retsError->Truncate(lstrlen(pDest)); } return false; } } // Seek to the proper position MCIWndSeek(m_hMusic, Max(0, Min(iPos, State.iLength))); // Play it if (MCIWndPlay(m_hMusic) != 0) return false; // Done return true; } catch (...) { return false; } }
static long audio_set_time(javacall_handle handle, long ms){ audio_handle* pHandle = (audio_handle*)handle; audio_prepare_MCIWnd(pHandle); if (pHandle->hWnd) { long real_ms = MCIWndSeek(pHandle->hWnd, ms); pHandle->offset = ms; return ms; } return -1; }
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_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; }