예제 #1
0
 virtual void rewind()
 {
     libvlc_media_player_stop( _vlcPlayer );
     libvlc_media_player_set_time( _vlcPlayer, 0 );
     libvlc_media_player_next_frame( _vlcPlayer );
     _status = INVALID;
 }
예제 #2
0
파일: VLC.cpp 프로젝트: artcom/y60vlc
    void
    VLC::load(const std::string & theFilename) {

        AC_DEBUG << "VLC::load('" << theFilename << "')";

        _EOF = false;
        _playTime = 0;
        
        std::vector<std::string> elements = asl::splitString(theFilename, "#");
        if (elements.size() == 2) {
            _playTime = as<asl::Unsigned64>(elements[1]);
            AC_DEBUG << "parsed playback position at " << _playTime << " milliseconds.";
        }
        
        _mediaURL = elements[0];
        libvlc_media_t *media = libvlc_media_new_location(_libvlc, _mediaURL.c_str());
        libvlc_media_player_set_media(_mediaPlayer, media);
        libvlc_media_release(media);

        libvlc_video_set_callbacks(_mediaPlayer, VLC::lock, VLC::unlock, VLC::display, this);
        _rasterEncoding = BGR;
        setPixelFormat(_rasterEncoding);
        libvlc_video_set_format_callbacks(_mediaPlayer, VLC::setup_video, VLC::cleanup_video);

        libvlc_media_player_play(_mediaPlayer);
        if (_playTime > 0) {
            libvlc_media_player_set_time(_mediaPlayer, _playTime);
        }
    }
예제 #3
0
void
AudioOutput::seek( qint64 milliseconds )
{
    tDebug() << Q_FUNC_INFO;

    switch ( m_currentState )
    {
        case Playing:
        case Paused:
        case Loading:
        case Buffering:
            break;
        default:
            return;
    }

    if ( m_seekable )
    {

        //    tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking" << milliseconds << "msec";
        libvlc_media_player_set_time( m_vlcPlayer, milliseconds );
        setCurrentTime( milliseconds );
    }
    else
    {
        qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
        float position = float(float(milliseconds) / duration);
        libvlc_media_player_set_position(m_vlcPlayer, position);
        tDebug() << Q_FUNC_INFO << "AudioOutput:: seeking via position" << position << "pos";
    }
    m_justSeeked = true;
}
예제 #4
0
void VPlayer::setTime(qint64 _time)
{
	if(mp){
		libvlc_media_player_set_time(mp,_time);
		emit jumped(_time);
	}
}
예제 #5
0
void VideoWindow::seekPlayback(long ms)
{
    if (!m) return;

    // seek to ms position in current file
    libvlc_media_player_set_time(mp, (libvlc_time_t) ms);
}
예제 #6
0
파일: xmrplayer.c 프로젝트: dereky7/xmradio
void
xmr_player_set_time(XmrPlayer	*player,
			gint64		 newtime)
{
	g_return_if_fail(player != NULL);
	
	libvlc_media_player_set_time(player->priv->player, newtime);
}
예제 #7
0
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);
}
예제 #8
0
STDMETHODIMP VLCInput::put_time(double time)
{
    libvlc_media_player_t *p_md;
    HRESULT hr = getMD(&p_md);
    if( SUCCEEDED(hr) )
    {
        libvlc_media_player_set_time(p_md, (int64_t)time);
    }
    return hr;
};
예제 #9
0
bool VLCVideoWrapper::seek(Real64 SeekPos)
{
    SeekPos = osgClamp<Real64>(0,SeekPos,getDuration());
    Real64 SeekInMS(SeekPos*1000.0);
    // jump the vid to SeekPos ms into the video
    libvlc_media_player_set_time(_MediaPlayer, SeekInMS);
    bool error = checkVLCError("seeking");

    // will return true if no errors occured
    return !error;
}
예제 #10
0
void
Java_org_videolan_libvlc_MediaPlayer_setTime(JNIEnv *env, jobject thiz,
                                             jlong time)
{
    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);

    if (!p_obj)
        return;

    libvlc_media_player_set_time(p_obj->u.p_mp, time);
}
예제 #11
0
static void
_position_set(struct _App *app)
{
   if (!app->mp)
     return;

   float position;
   _em_read_safe(app->em_read, &position, sizeof(position));

   libvlc_time_t new_time = position * 1000;
   libvlc_media_player_set_time(app->mp, new_time);
}
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;
    }
}
예제 #13
0
/* Sets the media position */
void
mediacontrol_set_media_position( mediacontrol_Instance *self,
                                 const mediacontrol_Position * a_position,
                                 mediacontrol_Exception *exception )
{
    libvlc_exception_t ex;
    int64_t i_pos;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    i_pos = private_mediacontrol_position2microsecond( self->p_media_player, a_position );
    libvlc_media_player_set_time( self->p_media_player, i_pos / 1000, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
예제 #14
0
	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);
	}
예제 #15
0
bool VlcVideoWidget::Seek(s64 time)
{
    if (vlcPlayer_)
    {
        if (libvlc_media_player_is_playing(vlcPlayer_))
        {
            if (libvlc_media_player_is_seekable(vlcPlayer_))
            {
                libvlc_media_player_set_time(vlcPlayer_, time);
                return true;
            }
        }
    }
    return false;
}
예제 #16
0
파일: VLC.cpp 프로젝트: artcom/y60vlc
 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);    
             }
         }
     }
 };
예제 #17
0
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);
    }
}
예제 #18
0
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);
    }
}
예제 #19
0
bool VLCVideoWrapper::jump(Real64 Amount)
{
    Amount = osgClamp<Real64>(0,getPosition()+Amount,getDuration());
    Real64 AmountInMS(Amount*1000.0);

    // getting the current time in the movie and adding it to the desired time to jump
    // checking if there was an error gettin the time
    bool error = checkVLCError("jumping");
    // no error? excellent, then jump fwd/bkwd Amount ms
    if(!error)
    {
        // GO to 'amount' time in the video
        libvlc_media_player_set_time(_MediaPlayer, AmountInMS);
        // more error checking
        error = checkVLCError("jumping");

    }
    // will return true if no errors occured
    return !error;
}
예제 #20
0
static void
_play(struct _App *app)
{
   float pos;

   if (!app->mp)
     return;

   _em_read_safe(app->em_read, &pos, sizeof(pos));

   if (app->playing)
     {
	libvlc_media_player_set_pause(app->mp, 0);
     }
   else
     {
	libvlc_time_t new_time = pos * 1000;
	libvlc_media_player_play(app->mp);
	libvlc_media_player_set_time(app->mp, new_time);
	app->playing = 1;
     }
}
예제 #21
0
void VlcMediaPlayer::setTime(const int &time)
{
    libvlc_media_player_set_time(_vlcMediaPlayer, time);

    VlcError::errmsg();
}
예제 #22
0
	void VLCWrapper::setTime (qint64 time)
	{
		libvlc_media_player_set_time (Player_.get (), time);
	}
bool VLCVideoTextureObjChunk::createVLCInstance(libvlc_time_t start_time, 
                                                bool          play      )
{
    libvlc_media_t *m;
    
    char const *vlc_argv[] =
    {       
        "-I", "dumy",      // No special interface
        "--ignore-config", // Don't use VLC's config        
        "--quiet",         // deactivates VLCs console outputs
        "--no-xlib",       // tell VLC to not use Xlib                   
        "--no-video-title-show", // no titles
    };
        
    int vlc_argc        = sizeof(vlc_argv       ) / sizeof(*vlc_argv       );
         
    // Initialize libVLC   
    if (libvlc==NULL) 
    {        
        libvlc = libvlc_new(vlc_argc, vlc_argv);        
    } 
    else 
    {
        if (vlcmediaplayer!=NULL) 
        {
            ctx.idstr = NULL;
            libvlc_media_player_stop(vlcmediaplayer);    
            libvlc_media_player_release(vlcmediaplayer);
            vlcmediaplayer = NULL;
            if (ctx.videothread!=NULL) {
                ctx.videothread->runFunction(NULL,NULL); // reset thread structure: isInititialized=false
            }
            ctx.videothread = NULL;            
        }
    }
    m = libvlc_media_new_path(libvlc, getUrl().c_str());
   
    vlcmediaplayer = libvlc_media_player_new_from_media(m);
   
    libvlc_media_release(m);

    ctx.idstr = strdup((std::string("video")+getVideoID()).c_str());
    ctx.videothread = NULL;            
    ctx.img = Image::create();
    ctx.img->set(OSG::Image::OSG_BGR_PF,getWidth(), getHeight());
    ctx.lock = Lock::create();
    
    this->setImage(ctx.img);
    this->setTarget(GL_TEXTURE_2D);
    ctx.self = this;


    vlceventmgr = libvlc_media_player_event_manager( vlcmediaplayer );
    // attach event to defined event handler callback
    libvlc_event_attach( vlceventmgr, libvlc_MediaPlayerEndReached, vlc_event, &ctx);

    libvlc_video_set_callbacks(vlcmediaplayer, vlc_lock, vlc_unlock, vlc_display, &ctx);
    libvlc_video_set_format(vlcmediaplayer, "RV24", getWidth(), getHeight(), getWidth()*3);
    if (getIsMaster()==false) libvlc_audio_set_mute(vlcmediaplayer, 1);
    
#if 0
    {
        SLOG << "available filters:" << std::endl;
        libvlc_module_description_t *list = libvlc_video_filter_list_get(libvlc);
        libvlc_module_description_t *iter = list;
        while(iter!=NULL) {
            SLOG << iter->psz_name << std::endl;
            iter = iter->p_next;
        }                
        libvlc_module_description_list_release(list);
    }
#endif
        

    libvlc_media_player_play(vlcmediaplayer);
    libvlc_media_player_set_time(vlcmediaplayer, start_time);
    if (!play) libvlc_media_player_pause(vlcmediaplayer); //not working?
    
    // add to static list
    //allVideoTextures.push_back(&ctx);

    lastSync=OSG::getTimeStamp();

    return true;
}
예제 #24
0
/**
 * @brief Set point of time in playback
 *
 * @param player \e GtkVlcPlayer instance
 * @param time   New position in media (milliseconds)
 */
void
gtk_vlc_player_seek(GtkVlcPlayer *player, gint64 time)
{
	libvlc_media_player_set_time(player->priv->media_player,
				     (libvlc_time_t)time);
}
예제 #25
0
 virtual void setReferenceTime( double time ) { libvlc_media_player_set_time(_vlcPlayer, (int)time); }
예제 #26
0
void VideoPlayer::rewind()
{
    libvlc_media_player_stop( _vlcPlayer );
    libvlc_media_player_set_time( _vlcPlayer, 0 );
    _status = INVALID;
}
예제 #27
0
void Java_org_videolan_libvlc_LibVLC_setTime(JNIEnv *env, jobject thiz, jlong time)
{
    libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
    if (mp)
        libvlc_media_player_set_time(mp, time);
}
예제 #28
0
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;
}
예제 #29
0
void VlcMediaWidget::seek(int time)
{
	libvlc_media_player_set_time(vlcMediaPlayer, time);
}
예제 #30
0
void VLCWrapperImpl::SetTime( int64_t newTime )
{
    libvlc_media_player_set_time(pMediaPlayer_,(libvlc_time_t)newTime);
}