int player::getTime() { if (mp) { // if player is initialise return the time return libvlc_media_player_get_time(mp); } else { return 0; } }
jlong Java_org_videolan_libvlc_LibVLC_getTime(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = getMediaPlayer(env, thiz); if (mp) return libvlc_media_player_get_time(mp); return -1; }
gint64 xmr_player_get_time(XmrPlayer *player) { g_return_val_if_fail(player != NULL, 0L); return libvlc_media_player_get_time(player->priv->player); }
void NPlaybackEngineVlc::jump(qint64 msec) { if (!hasMedia() || !libvlc_media_player_is_seekable(m_mediaPlayer)) return; qint64 posMsec = qBound(0LL, libvlc_media_player_get_time(m_mediaPlayer) + msec, durationMsec()); libvlc_media_player_set_time(m_mediaPlayer, posMsec); }
int VlcMediaPlayer::time() const { libvlc_time_t time = libvlc_media_player_get_time(_vlcMediaPlayer); VlcError::errmsg(); return time; }
int play_isoverthirtymark(struct info *data) { if (libvlc_media_player_get_time(data->vlc_mp) >= (30 * 1000)) return TRUE; else return FALSE; }
void VLCFullScreenWnd::SyncVideoPosScrollPosWithVideoPos() { libvlc_media_player_t* p_md = getMD(); if( p_md ){ libvlc_time_t pos = libvlc_media_player_get_time(p_md); SetVideoPosScrollPosByVideoPos(pos); } }
__int64 CAVPlayer::GetTime() { if (m_pVLC_Player) { return libvlc_media_player_get_time(m_pVLC_Player); } return 0; }
int64_t media_get_time() { if(mediaplay != NULL) { return libvlc_media_player_get_time(mediaplay); } return -1; }
JNIEXPORT jint JNICALL NAME(nativeGetCurrentPosition)(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); int64_t position = libvlc_media_player_get_time(mp); if (position < 0) { return -1; } return (jint) (position / 1000); }
jlong Java_org_videolan_libvlc_MediaPlayer_getTime(JNIEnv *env, jobject thiz) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return -1; return libvlc_media_player_get_time(p_obj->u.p_mp); }
Real64 VLCVideoWrapper::getPosition(void) const { // grabbing the time in ms // libvlc_time_t is just a typedef for a 64 bit integer libvlc_time_t currentTime = libvlc_media_player_get_time(_MediaPlayer); bool error = checkVLCError("getting position"); //Convert into seconds return static_cast<Real64>(currentTime) / 1000.0; }
void VLCVideoTextureObjChunk::updateTime(void) { if ((libvlc == NULL) || (vlcmediaplayer == NULL)) return; if (libvlc_media_player_is_playing(vlcmediaplayer)!=1) return; // only update if > MIN_TIME_DIFF ms offset long test=labs(libvlc_media_player_get_time(vlcmediaplayer)-this->getTimestamp()); if (test>MIN_TIME_DIFF) { libvlc_media_player_set_time(vlcmediaplayer, this->getTimestamp()); SLOG << "resyncing video: " << test << std::endl; } }
void VLCVideoTextureObjChunk::resizeVideo() { if ((libvlc == NULL) || (vlcmediaplayer == NULL)) return; libvlc_time_t current_time=0; bool play = true; if (libvlc_media_player_is_playing(vlcmediaplayer)!=1) play=false; current_time = libvlc_media_player_get_time(vlcmediaplayer); SINFO << "restart video at " << current_time << std::endl; createVLCInstance(current_time,play); }
STDMETHODIMP VLCInput::get_time(double* time) { if( NULL == time ) return E_POINTER; libvlc_media_player_t *p_md; HRESULT hr = getMD(&p_md); if( SUCCEEDED(hr) ) { *time = (double)libvlc_media_player_get_time(p_md); } return hr; };
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(); }
void VLCWrapper::setWindow (WId winId) { libvlc_media_player_t *m = Player_.get (); int time = libvlc_media_player_get_time (m); libvlc_media_player_stop (m); #ifdef Q_OS_WIN32 libvlc_media_player_set_hwnd (m, winId); #endif #ifdef Q_WS_X11 libvlc_media_player_set_xwindow (m, winId); #endif libvlc_media_player_play (m); libvlc_media_player_set_time (m, time); }
void CAVPlayer::SeekBackward() { //int iPos = GetPos(); //SeekTo((int)floor(iPos * 0.9)); if (m_pVLC_Player) { libvlc_time_t i_time = libvlc_media_player_get_time(m_pVLC_Player) - 5000; if (i_time < 0) { i_time = 0; } libvlc_media_player_set_time(m_pVLC_Player, i_time); } }
void VLCVideoTextureObjChunk::checkForSync(void) { if ((libvlc == NULL) || (vlcmediaplayer == NULL)) return; if (libvlc_media_player_is_playing(vlcmediaplayer)!=1) return; // only the master sets the timestamp if (getIsMaster()==true) { OSG::TimeStamp now = OSG::getTimeStamp(); if (OSG::getTimeStampMsecs(now-lastSync) > getUpdatefreq()) { lastSync=now; setTimestamp(libvlc_media_player_get_time(vlcmediaplayer)+NETWORK_LATENCY); commitChanges(); } } }
void VlcMediaWidget::updateCurrentTotalTime() { currentTime = int(libvlc_media_player_get_time(vlcMediaPlayer)); totalTime = int(libvlc_media_player_get_length(vlcMediaPlayer)); if (currentTime < 0) { currentTime = 0; } if (totalTime < 0) { totalTime = 0; } if (currentTime > totalTime) { currentTime = totalTime; } }
void CAVPlayer::SeekForward() { //int iPos = GetPos(); //SeekTo((int)ceil(iPos * 1.1)); // 一次快退5秒 if (m_pVLC_Player) { libvlc_time_t i_time = libvlc_media_player_get_time(m_pVLC_Player) + 5000; if (i_time > GetTotalTime()) { i_time = GetTotalTime(); } libvlc_media_player_set_time(m_pVLC_Player, i_time); } }
void VLCPlayer::handleEvent(const libvlc_event_t* pEvt, void * pUserData) { libvlc_time_t time; switch(pEvt->type) { case libvlc_MediaPlayerTimeChanged: time = libvlc_media_player_get_time(VLCPlayer::media_player); //qDebug() << "MediaPlayerTimeChanged " << time << " ms"; break; case libvlc_MediaPlayerEndReached: qDebug() << "MediaPlayerEndReached"; VLCPlayer::mutex.lock(); VLCPlayer::playbackInProgress = false; VLCPlayer::mutex.unlock(); break; default: printf("%s\n", libvlc_event_type_name(pEvt->type)); } if (VLCPlayer::handler) VLCPlayer::handler -> handleEvent(pEvt, pUserData); }
void VLC::readFrame(dom::ResizeableRasterPtr theTargetRaster) { ScopeLocker myFrameLock(_myFrameLock, true); if (_curBuffer == NULL) { return; } if (getFrameWidth() != _myFrameWidth) setFrameWidth(_myFrameWidth); if (getFrameHeight() != _myFrameHeight) setFrameHeight(_myFrameHeight); theTargetRaster->resize(getFrameWidth(), getFrameHeight()); std::copy(_curBuffer->begin(), _curBuffer->end(), theTargetRaster->pixels().begin()); libvlc_time_t curTimeCode = libvlc_media_player_get_time(_mediaPlayer); AC_TRACE << "-- timestamp from vlc: " << curTimeCode; setTimeCode(as_string(curTimeCode)); // delete the current buffer, marking that we already copied it to the texture AC_TRACE << "freeing " << _curBuffer->size() << " bytes after copying to texture."; delete _curBuffer; _curBuffer = NULL; }
/************************************************************************** * Playback management **************************************************************************/ mediacontrol_Position* mediacontrol_get_media_position( mediacontrol_Instance *self, const mediacontrol_PositionOrigin an_origin, const mediacontrol_PositionKey a_key, mediacontrol_Exception *exception ) { mediacontrol_Position* retval = NULL; libvlc_exception_t ex; int64_t pos; mediacontrol_exception_init( exception ); libvlc_exception_init( &ex ); retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) ); retval->origin = an_origin; retval->key = a_key; if( an_origin != mediacontrol_AbsolutePosition ) { free( retval ); /* Relative or ModuloPosition make no sense */ RAISE_NULL( mediacontrol_PositionOriginNotSupported, "Only absolute position is valid." ); } /* We are asked for an AbsolutePosition. */ pos = libvlc_media_player_get_time( self->p_media_player, &ex ); if( a_key == mediacontrol_MediaTime ) { retval->value = pos; } else { retval->value = private_mediacontrol_unit_convert( self->p_media_player, mediacontrol_MediaTime, a_key, pos ); } return retval; }
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)); }
long VlcVideoPlayer::getTimeMs() { return libvlc_media_player_get_time(vlcPlayer); }
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; }
int main(int argc, char **argv) { // having these declarations at the start of the function is only needed for C compatibility int i; char *path; char **vlc_argv; char *soutOption; int nr; libvlc_instance_t *vlc; libvlc_media_t *media; libvlc_media_player_t *player; libvlc_event_manager_t *eventManager; // init arguments if(argc < 3) { printf(ENDLN("Usage: vlcwrapper <input> <soutstring> [optional vlc arguments]")); return 1; } // print some information path = argv[1]; fprintf(stdout, ENDLN("I VLCWrapper version %s, using VLC %s"), VERSION, libvlc_get_version()); fprintf(stdout, ENDLN("A path %s"), path); fprintf(stdout, ENDLN("A config %s"), argv[2]); // init state machine global_state = STATE_NULL; // arguments (you shouldn't need these in normal usage; but we don't support all arguments by ourself yet) nr = argc - 3; vlc_argv = (char**)malloc(sizeof(char*)*nr); for(i = 3; i < argc; i++) { vlc_argv[i-3] = (char*)malloc(sizeof(char)* (strlen(argv[i]) + 1)); strcpy(vlc_argv[i-3], argv[i]); } for(i = 0; i < nr; i++) fprintf(stdout, ENDLN("A cmd %d %s"), i, vlc_argv[i]); // init vlc vlc = libvlc_new(nr, vlc_argv); libvlc_set_user_agent(vlc, USER_AGENT, HTTP_USER_AGENT); // create media and set sout string media = libvlc_media_new_path(vlc, path); soutOption = (char*)malloc(strlen(argv[2]) * sizeof(char) + 6); snprintf(soutOption, strlen(argv[2]) + 6, "sout=%s", argv[2]); libvlc_media_add_option(media, soutOption); // create player and listen for events player = libvlc_media_player_new_from_media(media); eventManager = libvlc_media_player_event_manager(player); register_event(eventManager, libvlc_MediaPlayerPlaying, STATE_PLAYING); register_event(eventManager, libvlc_MediaPlayerEncounteredError, STATE_ERROR); register_event(eventManager, libvlc_MediaPlayerEndReached, STATE_FINISHED); // start playing it libvlc_media_player_play(player); // wait till it's started or stopped because of an error while(global_state != STATE_ERROR && global_state != STATE_PLAYING) millisleep(100); // let it play till it has finished, while printing status information while(global_state == STATE_PLAYING) { fprintf(stdout, ENDLN("P %d"), libvlc_media_player_get_time(player)); fflush(stdout); millisleep(LOG_INTERVAL); } // stop playing libvlc_media_player_stop(player); // release objects in memory libvlc_media_release(media); libvlc_media_player_release(player); libvlc_release(vlc); return 0; }
qint64 VPlayer::getTime() { return state==Stop?-1:libvlc_media_player_get_time(mp); }
int VLCWrapper::GetTime () const { return libvlc_media_player_get_time (Player_.get ()); }