STDMETHODIMP VLCInput::get_fps(double* fps) { if( NULL == fps ) return E_POINTER; *fps = 0.0; libvlc_media_player_t *p_md; HRESULT hr = getMD(&p_md); if( SUCCEEDED(hr) ) { *fps = libvlc_media_player_get_fps(p_md); } return hr; };
void VLCAudioPlayer::checkFrame() { static int framenb = -1; fps = libvlc_media_player_get_fps(mediaPlayer, &vlc_ex); length = libvlc_media_player_get_length(mediaPlayer, &vlc_ex); float pos = libvlc_media_player_get_position(mediaPlayer, &vlc_ex); qDebug() << pos; int frame = ((length * fps) / 1000) * pos; if ((int) frame != framenb) { framenb = frame; emit frameChanged(framenb); } }
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result) { /* is plugin still running */ if( isPluginRunning() ) { VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); libvlc_exception_t ex; libvlc_exception_init(&ex); libvlc_media_player_t *p_md = p_plugin->getMD(&ex); if( libvlc_exception_raised(&ex) ) { if( index != ID_input_state ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); libvlc_exception_clear(&ex); return INVOKERESULT_GENERIC_ERROR; } else { /* for input state, return CLOSED rather than an exception */ INT32_TO_NPVARIANT(0, result); libvlc_exception_clear(&ex); return INVOKERESULT_NO_ERROR; } } switch( index ) { case ID_input_length: { double val = (double)libvlc_media_player_get_length(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); DOUBLE_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_position: { double val = libvlc_media_player_get_position(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); DOUBLE_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_time: { double val = (double)libvlc_media_player_get_time(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); DOUBLE_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_state: { int val = libvlc_media_player_get_state(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); INT32_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_rate: { float val = libvlc_media_player_get_rate(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); DOUBLE_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_fps: { double val = libvlc_media_player_get_fps(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); DOUBLE_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } case ID_input_hasvout: { bool val = p_plugin->player_has_vout(&ex); RETURN_ON_EXCEPTION(this,ex); BOOLEAN_TO_NPVARIANT(val, result); return INVOKERESULT_NO_ERROR; } default: ; } } return INVOKERESULT_GENERIC_ERROR; }