bool VLCVideoWrapper::setRate(Real64 Rate) { // set the playback rate libvlc_media_player_set_rate(_MediaPlayer, Rate); bool error = checkVLCError("setting player rate"); // will return true if no errors occured return !error; }
void mediacontrol_set_rate( mediacontrol_Instance *self, const int rate, mediacontrol_Exception *exception ) { mediacontrol_exception_init( exception ); libvlc_media_player_set_rate( self->p_media_player, rate * 10 ); }
STDMETHODIMP VLCInput::put_rate(double rate) { libvlc_media_player_t *p_md; HRESULT hr = getMD(&p_md); if( SUCCEEDED(hr) ) { libvlc_media_player_set_rate(p_md, rate); } return hr; };
void Java_org_videolan_libvlc_MediaPlayer_setRate(JNIEnv *env, jobject thiz, jfloat rate) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return; libvlc_media_player_set_rate(p_obj->u.p_mp, rate); }
static void _speed_set(struct _App *app) { float rate; if (!app->mp) return; _em_read_safe(app->em_read, &rate, sizeof(rate)); libvlc_media_player_set_rate(app->mp, rate); }
void VideoWindow::setSpeed(int val) { qreal speed; if(val > 0){ speed = 1+double(val); } else { speed = 1+double(val)/10; } if(speed==0) speed=0.05; QString l = QString::number(speed,'f',1)+"x"; if(speed==1) l = "Normal"; libvlc_media_player_set_rate(this->_player->core(),speed); VlcError::errmsg(); this->ui->l_speed->setText(l); }
void Java_org_videolan_libvlc_LibVLC_setRate(JNIEnv *env, jobject thiz, jfloat rate) { libvlc_media_player_t* mp = getMediaPlayer(env, thiz); if(mp) libvlc_media_player_set_rate(mp, rate); }
int transcode_stream::transcode_process(platform::process &process) { std::vector<std::string> vlc_options; vlc_options.push_back("--no-sub-autodetect-file"); if (compare_version(instance::version(), "2.1") >= 0) vlc_options.push_back("--avcodec-fast"); int font_size = -1; process >> font_size; if (font_size > 0) { vlc_options.push_back("--freetype-fontsize"); vlc_options.push_back(std::to_string(font_size)); } vlc::instance instance(vlc_options); std::string mrl, transcode, mux; process >> mrl >> transcode >> mux; std::ostringstream sout; sout << ":sout=" << from_percent(transcode) << ":std{access=fd,mux=" << mux << ",dst=" << process.output_fd() << "}"; auto media = media::from_mrl(instance, mrl); libvlc_media_add_option(media, sout.str().c_str()); std::string subtitle_file; process >> subtitle_file; if (subtitle_file != "(none)") { std::string file = from_percent(subtitle_file); #ifdef WIN32 file = from_utf16(platform::to_windows_path(file)); #endif libvlc_media_add_option(media, (":sub-file=" + file).c_str()); } size_t num_options = 0; process >> num_options; for (size_t i = 0; i < num_options; i++) { std::string option; process >> option; libvlc_media_add_option(media, from_percent(option).c_str()); } struct T { static void callback(const libvlc_event_t *e, void *opaque) { T * const t = reinterpret_cast<T *>(opaque); std::lock_guard<std::mutex> _(t->mutex); if (e->type == libvlc_MediaPlayerTimeChanged) { if (t->info) t->info->time = e->u.media_player_time_changed.new_time; } else if (e->type == libvlc_MediaPlayerPlaying) { t->started = true; if (t->track_ids.video >= -1) { libvlc_video_set_track(t->player, -1); if (t->track_ids.video > 0) libvlc_video_set_track(t->player, t->track_ids.video); } if (t->track_ids.audio >= -1) { libvlc_audio_set_track(t->player, -1); if (t->track_ids.audio >= 0) libvlc_audio_set_track(t->player, t->track_ids.audio); } if (t->track_ids.text >= -1) { libvlc_video_set_spu(t->player, -1); if (t->track_ids.text >= 0) libvlc_video_set_spu(t->player, t->track_ids.text); } } else if (e->type == libvlc_MediaPlayerEndReached) { t->end_reached = true; if (t->info) t->info->end_reached = true; } else if (e->type == libvlc_MediaPlayerEncounteredError) t->encountered_error = true; t->condition.notify_one(); } volatile shared_info *info; struct track_ids track_ids; std::mutex mutex; std::condition_variable condition; bool started; bool end_reached; bool encountered_error; libvlc_media_player_t *player; } t; unsigned info_offset(-1); process >> info_offset; process >> t.track_ids.audio >> t.track_ids.video >> t.track_ids.text; int chapter = -1; int64_t position = -1; float rate = 0.0f; process >> chapter >> position >> rate; t.info = &process.get_shared<shared_info>(info_offset); t.started = false; t.end_reached = false; t.encountered_error = false; t.player = libvlc_media_player_new_from_media(media); if (t.player) { auto event_manager = libvlc_media_player_event_manager(t.player); libvlc_event_attach(event_manager, libvlc_MediaPlayerTimeChanged, &T::callback, &t); libvlc_event_attach(event_manager, libvlc_MediaPlayerPlaying, &T::callback, &t); libvlc_event_attach(event_manager, libvlc_MediaPlayerEndReached, &T::callback, &t); libvlc_event_attach(event_manager, libvlc_MediaPlayerEncounteredError, &T::callback, &t); if (libvlc_media_player_play(t.player) == 0) { std::unique_lock<std::mutex> l(t.mutex); while (!t.end_reached && !t.encountered_error && process) { if (t.started) { l.unlock(); if (chapter >= 0) libvlc_media_player_set_chapter(t.player, chapter); if (position > 0) libvlc_media_player_set_time(t.player, position); if (std::abs(rate - 1.0f) > 0.01f) libvlc_media_player_set_rate(t.player, rate); l.lock(); t.started = false; } t.condition.wait(l); } l.unlock(); libvlc_media_player_stop(t.player); } libvlc_event_detach(event_manager, libvlc_MediaPlayerEncounteredError, &T::callback, &t); libvlc_event_detach(event_manager, libvlc_MediaPlayerEndReached, &T::callback, &t); libvlc_event_detach(event_manager, libvlc_MediaPlayerPlaying, &T::callback, &t); libvlc_event_detach(event_manager, libvlc_MediaPlayerTimeChanged, &T::callback, &t); libvlc_media_player_release(t.player); } return 0; }
RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const NPVariant &value) { /* 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); RETURN_ON_EXCEPTION(this,ex); switch( index ) { case ID_input_position: { if( ! NPVARIANT_IS_DOUBLE(value) ) { return INVOKERESULT_INVALID_VALUE; } float val = (float)NPVARIANT_TO_DOUBLE(value); libvlc_media_player_set_position(p_md, val, &ex); RETURN_ON_EXCEPTION(this,ex); return INVOKERESULT_NO_ERROR; } case ID_input_time: { int64_t val; if( NPVARIANT_IS_INT32(value) ) val = (int64_t)NPVARIANT_TO_INT32(value); else if( NPVARIANT_IS_DOUBLE(value) ) val = (int64_t)NPVARIANT_TO_DOUBLE(value); else { return INVOKERESULT_INVALID_VALUE; } libvlc_media_player_set_time(p_md, val, &ex); RETURN_ON_EXCEPTION(this,ex); return INVOKERESULT_NO_ERROR; } case ID_input_rate: { float val; if( NPVARIANT_IS_INT32(value) ) val = (float)NPVARIANT_TO_INT32(value); else if( NPVARIANT_IS_DOUBLE(value) ) val = (float)NPVARIANT_TO_DOUBLE(value); else { return INVOKERESULT_INVALID_VALUE; } libvlc_media_player_set_rate(p_md, val, &ex); RETURN_ON_EXCEPTION(this,ex); return INVOKERESULT_NO_ERROR; } default: ; } } return INVOKERESULT_GENERIC_ERROR; }