rsked/vlcplayer.cc
/// Start playing the source.  If src is NULL, then no further actions
/// are taken.  Anything currently playing is stopped.  The playlist is
/// cleared and only the source will be scheduled to play.  It will
/// verify that VLC is usable; if the process or connection had not
/// been initiated, it will be launched now: this is a suitable way to
/// start the VLC process/connection.
///
/// * May throw various flavors of Player_exception()
///
Start playing the source.  If src is NULL, then no further actions
are taken.  Anything currently playing is stopped.  The playlist is
cleared and only the source will be scheduled to play.  It will
verify that VLC is usable; if the process or connection had not
been initiated, it will be launched now: this is a suitable way to
start the VLC process/connection.

May throw various flavors of Player_exception()
Start playing the source . If src is NULL then no further actions are taken . Anything currently playing is stopped . The playlist is cleared and only the source will be scheduled to play . It will verify that VLC is usable ; if the process or connection had not been initiated it will be launched now : this is a suitable way to start the VLC process / connection . May throw various flavors of Player_exception ()
void Vlc_player::play( spSource src )
{
    if (not m_enabled) {
        LOG_ERROR(Lgr) << m_name << " is disabled--cannot play";
        throw Player_media_exception();
    }
    if (m_testmode) {
        LOG_DEBUG(Lgr) << m_name << ": play command ignored in test mode";
        return;
    }
    if (!src) {     
        LOG_DEBUG(Lgr) << m_name << ": play null source, i.e. STOP";
        stop();
        return;
    }
    if (not has_cap(src->medium(),src->encoding())) {
        LOG_ERROR(Lgr) << m_name << "cannot play type of source in" << src->name();
        throw Player_media_exception();
    }
    assure_running();
    if (not m_usable) {
        LOG_ERROR(Lgr) << m_name << " is not usable--cannot play";
        throw Player_startup_exception();
    }
    do_command("stop\n",true);
    do_command("clear\n",true);
    if ( src->repeatp() ) {
        do_command("loop on\n",true);
    } else {
        do_command("loop off\n",true);
    }
    set_volume();
    std::string qcommand {"enqueue "};  
    std::string effpath;
    if (src->localp()) {
        boost::filesystem::path abspath {};
        if (not src->res_path( abspath )) { 
            throw Player_media_exception(); 
        }
        effpath = abspath.native();
    } else {
        effpath = src->resource();
    }
    qcommand += effpath;
    qcommand += "\n";
    do_command( qcommand, true );
    LOG_DEBUG(Lgr) << m_name << " enqueued: `" << effpath << "`";
    do_command( "goto 1\n", true ); 
    do_command( "play\n", true );
    if (m_debug) {
        do_command( "playlist\n", true );
    }
    m_src = src;  
    m_stall_counter = 0;
    m_last_elapsed_secs = 0;
    m_state = PlayerState::Playing; 
}
void Vlc_player :: play ( spSource src ) { if ( not m_enabled ) { LOG_ERROR ( Lgr ) << m_name << " " ; throw Player_media_exception ( ) ; } if ( m_testmode ) { LOG_DEBUG ( Lgr ) << m_name << " " ; return ; } if ( ! src ) { LOG_DEBUG ( Lgr ) << m_name << " " ; stop ( ) ; return ; } if ( not has_cap ( src -> medium ( ) , src -> encoding ( ) ) ) { LOG_ERROR ( Lgr ) << m_name << " " << src -> name ( ) ; throw Player_media_exception ( ) ; } assure_running ( ) ; if ( not m_usable ) { LOG_ERROR ( Lgr ) << m_name << " " ; throw Player_startup_exception ( ) ; } do_command ( " \n " , true ) ; do_command ( " \n " , true ) ; if ( src -> repeatp ( ) ) { do_command ( " \n " , true ) ; } else { do_command ( " \n " , true ) ; } set_volume ( ) ; std :: string qcommand { " " } ; std :: string effpath ; if ( src -> localp ( ) ) { boost :: filesystem :: path abspath { } ; if ( not src -> res_path ( abspath ) ) { throw Player_media_exception ( ) ; } effpath = abspath . native ( ) ; } else { effpath = src -> resource ( ) ; } qcommand += effpath ; qcommand += " \n " ; do_command ( qcommand , true ) ; LOG_DEBUG ( Lgr ) << m_name << " " << effpath << " " ; do_command ( " \n " , true ) ; do_command ( " \n " , true ) ; if ( m_debug ) { do_command ( " \n " , true ) ; } m_src = src ; m_stall_counter = 0 ; m_last_elapsed_secs = 0 ; m_state = PlayerState :: Playing ; }
Start playing the source.
Start playing the source .
// null src is not an error: means stop // Verify src is a valid type for Vlc // Note that the 'repeat' command will only repeat one track, not // a whole playlist or directory--use 'loop' to achieve that effect. // ------------------------------------------------------------------------ // Enqueue the resource: // note required trailing space // get the expanded absolute path // ??? best error to throw ??? // ------------------------------------------------------------------------ // essential for playlists // ...success // intended source // assume for now