void libvlc_media_player_set_pause( libvlc_media_player_t *p_mi, int paused ) { input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi ); if( !p_input_thread ) return; libvlc_state_t state = libvlc_media_player_get_state( p_mi ); if( state == libvlc_Playing || state == libvlc_Buffering ) { if( paused ) { if( libvlc_media_player_can_pause( p_mi ) ) input_Control( p_input_thread, INPUT_SET_STATE, PAUSE_S ); else input_Stop( p_input_thread, true ); } } else { if( !paused ) input_Control( p_input_thread, INPUT_SET_STATE, PLAYING_S ); } vlc_object_release( p_input_thread ); }
void VlcMediaWidget::updatePlaybackStatus() { playbackStatus = MediaWidget::Playing; switch (libvlc_media_player_get_state(vlcMediaPlayer)) { case libvlc_NothingSpecial: case libvlc_Stopped: // FIXME vlc state is not updated synchronously in libvlc_media_player_play if (libvlc_media_player_get_media(vlcMediaPlayer) == NULL) { playbackStatus = MediaWidget::Idle; } break; case libvlc_Opening: case libvlc_Buffering: case libvlc_Playing: playbackStatus = MediaWidget::Playing; break; case libvlc_Paused: playbackStatus = MediaWidget::Paused; break; case libvlc_Ended: case libvlc_Error: playbackStatus = MediaWidget::Idle; // don't keep last picture shown libvlc_media_player_stop(vlcMediaPlayer); break; } if (playbackStatus == MediaWidget::Idle) { addPendingUpdates(DvdMenu); playingDvd = false; } }
/************************************************************************** * Toggle pause. **************************************************************************/ void libvlc_media_player_pause( libvlc_media_player_t *p_mi ) { libvlc_state_t state = libvlc_media_player_get_state( p_mi ); bool playing = (state == libvlc_Playing || state == libvlc_Buffering); libvlc_media_player_set_pause( p_mi, playing ); }
/************************************************************************** * State (Public) **************************************************************************/ libvlc_state_t libvlc_media_list_player_get_state(libvlc_media_list_player_t * p_mlp) { if (!p_mlp->p_mi) return libvlc_Ended; return libvlc_media_player_get_state(p_mlp->p_mi); }
static void _file_close(struct _App *app) { app->playing = 0; if (app->opening) goto release_resources; if (libvlc_media_player_get_state(app->mp) != libvlc_Playing) { _send_file_closed(app); return; } app->closing = 1; release_resources: libvlc_media_player_stop(app->mp); if (app->filename) free(app->filename); if (app->mp) { libvlc_media_release(app->m); libvlc_media_player_release(app->mp); free(app->tmpbuffer); } }
/************************************************************************** * is_playing (Public) **************************************************************************/ int libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e) { libvlc_state_t state = libvlc_media_player_get_state(p_mlp->p_mi, p_e); return (state == libvlc_Opening) || (state == libvlc_Buffering) || (state == libvlc_Playing); }
jint Java_org_videolan_libvlc_LibVLC_getPlayerState(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = getMediaPlayer(env, thiz); if (mp) return (jint) libvlc_media_player_get_state(mp); return -1; }
/************************************************************************** * State (Public) **************************************************************************/ libvlc_state_t libvlc_media_list_player_get_state(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e) { if (!p_mlp->p_mi) return libvlc_Ended; return libvlc_media_player_get_state(p_mlp->p_mi, p_e); }
// retorna true si es un video, false en caso contrario // Si es un video ademas rellena los parametros Tiempo, nAncho y nAlto const bool InformacionArchivoEx::_AnalisisVLC(const TCHAR *Path, UINT64 &Tiempo, UINT &nAncho, UINT &nAlto, libvlc_instance_t *Instancia) { char Destino[2049]; size_t TamnTexto = wcslen(Path); int TamRes = WideCharToMultiByte(CP_UTF8, NULL, Path, TamnTexto, Destino, 2048, NULL, NULL); Destino[TamRes] = 0; libvlc_media_t *Media = NULL; libvlc_media_player_t *nMediaPlayer = NULL; Media = libvlc_media_new_path(Instancia, Destino); libvlc_media_parse(Media); libvlc_media_add_option(Media, "sout=#description:dummy"); nMediaPlayer = libvlc_media_player_new_from_media(Media); libvlc_state_t Estado = libvlc_Opening; libvlc_media_player_play(nMediaPlayer); //posible deadlock // Esperamos hasta que empieze el play while (Estado != libvlc_Playing && Estado != libvlc_Ended) { Estado = libvlc_media_player_get_state(nMediaPlayer); Sleep(100); if (Estado == libvlc_Error) { // Hay un error en la libvlc, salimos Sleep(300); // Nos aseguramos de que el log se escriba libvlc_media_player_stop(nMediaPlayer); libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); Tiempo = 0; nAncho = 0; nAlto = 0; return false; } } // Miramos los streams disponibles y buscamos el de video libvlc_media_track_info_t *TI = NULL; int z = libvlc_media_get_tracks_info(Media, &TI); for (int n = 0; n < z; n++) { if (TI->i_type == libvlc_track_video) { libvlc_media_player_stop(nMediaPlayer); Tiempo = 0; //libvlc_media_player_get_length(nMediaPlayer); // NO DA BIEN EL TIEMPO.............. nAncho = TI->u.video.i_width; nAlto = TI->u.video.i_height; libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); return true; } TI ++; } libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); // No hay streams de video retornamos false Tiempo = 0; nAncho = 0; nAlto = 0; return false; }
bool VLCVideoWrapper::isStopped(void) const { //Get the state of the medial player libvlc_state_t currentState = libvlc_media_player_get_state(_MediaPlayer); bool error = checkVLCError("getting pause state"); return currentState == libvlc_Stopped; }
int VLCWrapperImpl::GetPlayerState(void) { int nRet = 0; if ( m_pMediaPlayer ) { nRet = libvlc_media_player_get_state(m_pMediaPlayer, &m_VLCex); ProcessVLCException(&m_VLCex, m_EH); } return nRet; }
jint Java_org_videolan_libvlc_MediaPlayer_getPlayerState(JNIEnv *env, jobject thiz) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return -1; return (jint) libvlc_media_player_get_state(p_obj->u.p_mp); }
bool CPlayer::isTrackInErrorState() { if (mMediaPlayer && hasPlayerInstance) { libvlc_state_t playerState; playerState = libvlc_media_player_get_state(mMediaPlayer); return (playerState == libvlc_Error); } return false; }
/************************************************************************** * is_playing (Public) **************************************************************************/ int libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp) { if (!p_mlp->p_mi) { return libvlc_NothingSpecial; } libvlc_state_t state = libvlc_media_player_get_state(p_mlp->p_mi); return (state == libvlc_Opening) || (state == libvlc_Buffering) || (state == libvlc_Playing); }
int play_ended(struct info *data) { /* VLC states: IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, * PAUSE=4, STOPPING=5, ENDED=6, ERROR=7 */ if (libvlc_media_player_get_state(data->vlc_mp) >= 6) return TRUE; else return FALSE; }
void VLCMainwindow::updateInterface() { //Update interface and check if song is finished if(vlcPlayer) //It segfault if vlcPlayer don't exist { /* update the timeline */ float pos = libvlc_media_player_get_position(vlcPlayer); int siderPos=(int)(pos*(float)(1000)); slider->setValue(siderPos); /* Stop the media */ if (libvlc_media_player_get_state(vlcPlayer) == 6) { this->stop(); } } }
void Mwindow::updateInterface() { //Update interface and check if song is finished if (!vlcPlayer) return; /* update the timeline */ float pos = libvlc_media_player_get_position(vlcPlayer); slider->setValue((int)(pos*1000.0)); /* Stop the media */ if (libvlc_media_player_get_state(vlcPlayer) == libvlc_Ended) this->stop(); }
STDMETHODIMP VLCInput::get_state(long* state) { if( NULL == state ) return E_POINTER; libvlc_media_player_t *p_md; HRESULT hr = getMD(&p_md); if( SUCCEEDED(hr) ) { *state = libvlc_media_player_get_state(p_md); } return hr; };
bool VLCVideoWrapper::updateImage(void) { //VLC wants the current frame to be displayed if(_NextFrameReady) { if(getImage() == NULL) { _NextFrameReady = false; ImageUnrecPtr NewImage(Image::create()); setImage(NewImage); try { UInt32 Width(getWidth()), Height(getHeight()); _VideoMemContext._lock->acquire(); getImage()->set( #if BYTE_ORDER == LITTLE_ENDIAN Image::OSG_BGR_PF, #else Image::OSG_RGB_PF, #endif Width, Height, 1,1,1,0.0, reinterpret_cast<const UInt8*>(_VideoMemContext._pixels), Image::OSG_UINT8_IMAGEDATA); _VideoMemContext._lock->release(); } catch(...) { SWARNING << "VLCVideoWrapper::updateImage(): Error updateing Image object." << std::endl; setImage(NULL); return false; } } else { getImage()->setData(reinterpret_cast<const UInt8*>(_VideoMemContext._pixels)); } libvlc_state_t currentState = libvlc_media_player_get_state(_MediaPlayer); checkVLCError("Getting player state"); if(currentState == libvlc_Ended) { produceEnded(); } getImage()->mirror(false,true); } return true; }
int64_t PlayerEngine_vlc::get_media_time(){ if (!vlcPlayer) return 0; /* update the timeline */ return (int64_t)libvlc_media_player_get_time (vlcPlayer); /* Stop the media */ if (libvlc_media_player_get_state(vlcPlayer) == libvlc_Ended) this->stopState(); }
Vlc::State VlcMediaPlayer::state() const { // It's possible that the vlc doesn't play anything // so check before if (!libvlc_media_player_get_media(_vlcMediaPlayer)) return Vlc::Idle; libvlc_state_t state; state = libvlc_media_player_get_state(_vlcMediaPlayer); VlcError::errmsg(); return Vlc::State(state); }
void VLC::startCapture() { AC_DEBUG << "start capture"; if (_mediaPlayer) { _EOF = false; libvlc_media_player_play(_mediaPlayer); libvlc_state_t state = libvlc_media_player_get_state(_mediaPlayer); if (state != libvlc_Paused) { if (_playTime > 0) { AC_DEBUG << "seeking to playback position at " << _playTime << " milliseconds."; libvlc_media_player_set_time(_mediaPlayer, _playTime); } } } };
static gboolean clutter_vlc_get_playing(ClutterVlcVideoTexture* video_texture) { ClutterVlcVideoTexturePrivate* priv; libvlc_state_t vlc_state; priv = video_texture->priv; if (priv->vlc_media_player == NULL) return FALSE; vlc_state = libvlc_media_player_get_state(priv->vlc_media_player, &priv->vlc_exception); clutter_vlc_catch(&priv->vlc_exception); if (vlc_state != libvlc_Playing) return FALSE; return TRUE; }
Ibex::VLCVideoPlayer::~VLCVideoPlayer() { stopCapturing(); stopPlaying(); if(mp) { // Stop stream and clean up libVLC. while(libvlc_media_player_get_state(mp) != libvlc_Stopped) { libvlc_media_player_stop(mp); } libvlc_media_player_release(mp); mp = 0; } if(libvlc) { libvlc_release(libvlc); libvlc = 0; } if(context) { delete context; context = 0; } }
/************************************************************************** * Stop playing. **************************************************************************/ void libvlc_media_player_stop( libvlc_media_player_t *p_mi ) { libvlc_state_t state = libvlc_media_player_get_state( p_mi ); lock_input(p_mi); release_input_thread( p_mi, true ); /* This will stop the input thread */ /* Force to go to stopped state, in case we were in Ended, or Error * state. */ if( state != libvlc_Stopped ) { set_state( p_mi, libvlc_Stopped, false ); /* Construct and send the event */ libvlc_event_t event; event.type = libvlc_MediaPlayerStopped; libvlc_event_send( p_mi->p_event_manager, &event ); } input_resource_Terminate( p_mi->input.p_resource ); unlock_input(p_mi); }
void NPlaybackEngineVlc::checkStatus() { qreal pos = position(); if (m_oldPosition != pos) { m_oldPosition = pos; emit positionChanged(pos); } qreal vol = volume(); if (m_oldVolume != vol) { m_oldVolume = vol; emit volumeChanged(vol); } libvlc_state_t vlcState = libvlc_media_player_get_state(m_mediaPlayer); N::PlaybackState state = fromVlcState(vlcState); if (m_oldState != state) { emit stateChanged(state); m_oldState = state; } emit tick(libvlc_media_player_get_time(m_mediaPlayer)); }
/************************************************************************** * State (Public) **************************************************************************/ libvlc_state_t libvlc_media_list_player_get_state(libvlc_media_list_player_t * p_mlp) { return libvlc_media_player_get_state(p_mlp->p_mi); }
/************************************************************************** * is_playing (Public) **************************************************************************/ int libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp) { libvlc_state_t state = libvlc_media_player_get_state(p_mlp->p_mi); return (state == libvlc_Opening) || (state == libvlc_Playing); }
/************************************************************************** * Tells whether the media player is currently playing. * * Enter with lock held. **************************************************************************/ int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi ) { libvlc_state_t state = libvlc_media_player_get_state( p_mi ); return (libvlc_Playing == state) || (libvlc_Buffering == state); }
mediacontrol_StreamInformation * mediacontrol_get_stream_information( mediacontrol_Instance *self, mediacontrol_PositionKey a_key, mediacontrol_Exception *exception ) { (void)a_key; mediacontrol_StreamInformation *retval = NULL; libvlc_media_t * p_media; libvlc_exception_t ex; libvlc_exception_init( &ex ); retval = ( mediacontrol_StreamInformation* ) malloc( sizeof( mediacontrol_StreamInformation ) ); if( ! retval ) { RAISE( mediacontrol_InternalException, "Out of memory" ); return NULL; } p_media = libvlc_media_player_get_media( self->p_media_player, &ex ); HANDLE_LIBVLC_EXCEPTION_NULL( &ex ); if( ! p_media ) { /* No p_media defined */ retval->streamstatus = mediacontrol_UndefinedStatus; retval->url = strdup( "" ); retval->position = 0; retval->length = 0; } else { libvlc_state_t state; state = libvlc_media_player_get_state( self->p_media_player, &ex ); HANDLE_LIBVLC_EXCEPTION_NULL( &ex ); switch( state ) { case libvlc_NothingSpecial: retval->streamstatus = mediacontrol_UndefinedStatus; break; case libvlc_Opening : retval->streamstatus = mediacontrol_InitStatus; break; case libvlc_Buffering: retval->streamstatus = mediacontrol_BufferingStatus; break; case libvlc_Playing: retval->streamstatus = mediacontrol_PlayingStatus; break; case libvlc_Paused: retval->streamstatus = mediacontrol_PauseStatus; break; case libvlc_Stopped: retval->streamstatus = mediacontrol_StopStatus; break; case libvlc_Forward: retval->streamstatus = mediacontrol_ForwardStatus; break; case libvlc_Backward: retval->streamstatus = mediacontrol_BackwardStatus; break; case libvlc_Ended: retval->streamstatus = mediacontrol_EndStatus; break; case libvlc_Error: retval->streamstatus = mediacontrol_ErrorStatus; break; default : retval->streamstatus = mediacontrol_UndefinedStatus; break; } retval->url = libvlc_media_get_mrl( p_media, &ex ); retval->position = libvlc_media_player_get_time( self->p_media_player, &ex ); if( libvlc_exception_raised( &ex ) ) { libvlc_exception_clear( &ex ); retval->position = 0; } retval->length = libvlc_media_player_get_length( self->p_media_player, &ex ); if( libvlc_exception_raised( &ex ) ) { libvlc_exception_clear( &ex ); retval->length = 0; } } return retval; }