Changeset a2ccb9b4e1210d29a9578074636e6969e0bf8795

Show
Ignore:
Timestamp:
06/14/08 10:09:06 (3 months ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1213430946 +0200
git-parent:

[6a0f2d4686439e3691462abfd602172b023e9272]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1213088227 +0200
Message:

Use the same internal libvlc API as vlccontrol2.cpp does.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/activex/vlccontrol.cpp

    r763b673 ra2ccb9b  
    124124STDMETHODIMP VLCControl::play(void) 
    125125{ 
    126     libvlc_instance_t *p_libvlc; 
     126    libvlc_instance_t* p_libvlc; 
    127127    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    128128    if( SUCCEEDED(result) ) 
    129129    { 
    130         VLC_Play(i_vlc); 
     130        libvlc_exception_t ex; 
     131        libvlc_exception_init(&ex); 
     132 
     133        libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex); 
     134        if( libvlc_exception_raised(&ex) ) 
     135        { 
     136            _p_instance->setErrorInfo(IID_IVLCControl, 
     137                libvlc_exception_get_message(&ex)); 
     138            libvlc_exception_clear(&ex); 
     139            return E_FAIL; 
     140        } 
    131141        _p_instance->fireOnPlayEvent(); 
     142        return NOERROR; 
    132143    } 
    133144    return result; 
     
    136147STDMETHODIMP VLCControl::pause(void) 
    137148{ 
    138     libvlc_instance_t *p_libvlc; 
     149    libvlc_instance_t* p_libvlc; 
    139150    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    140151    if( SUCCEEDED(result) ) 
    141152    { 
    142         VLC_Pause(i_vlc); 
     153        libvlc_exception_t ex; 
     154        libvlc_exception_init(&ex); 
     155 
     156        libvlc_playlist_pause(p_libvlc, &ex); 
     157        if( libvlc_exception_raised(&ex) ) 
     158        { 
     159            _p_instance->setErrorInfo(IID_IVLCControl, 
     160                libvlc_exception_get_message(&ex)); 
     161            libvlc_exception_clear(&ex); 
     162            return E_FAIL; 
     163        } 
    143164        _p_instance->fireOnPauseEvent(); 
     165        return NOERROR; 
    144166    } 
    145167    return result; 
     
    148170STDMETHODIMP VLCControl::stop(void) 
    149171{ 
    150     libvlc_instance_t *p_libvlc; 
     172    libvlc_instance_t* p_libvlc; 
    151173    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    152174    if( SUCCEEDED(result) ) 
    153175    { 
    154         VLC_Stop(i_vlc); 
    155         _p_instance->fireOnStopEvent(); 
    156     } 
     176        libvlc_exception_t ex; 
     177        libvlc_exception_init(&ex); 
     178 
     179        libvlc_playlist_stop(p_libvlc, &ex); 
     180        if( libvlc_exception_raised(&ex) ) 
     181        { 
     182            _p_instance->setErrorInfo(IID_IVLCControl, 
     183                libvlc_exception_get_message(&ex)); 
     184            libvlc_exception_clear(&ex); 
     185            return E_FAIL; 
     186        } 
     187        return NOERROR; 
     188    } 
     189    _p_instance->fireOnStopEvent(); 
    157190    return result; 
    158191}; 
     
    185218    if( NULL == position ) 
    186219        return E_POINTER; 
    187  
     220    *position = 0.0f; 
     221 
     222    libvlc_instance_t* p_libvlc; 
    188223    HRESULT result = E_UNEXPECTED; 
    189     if( _p_instance->isRunning() ) 
    190     { 
    191         libvlc_instance_t *p_libvlc; 
    192         result = _p_instance->getVLC(&p_libvlc); 
    193         if( SUCCEEDED(result) ) 
    194         { 
    195             *position = VLC_PositionGet(i_vlc); 
    196             return NOERROR; 
    197         } 
    198     } 
    199     *position = 0.0f; 
     224    result = _p_instance->getVLC(&p_libvlc); 
     225    if( SUCCEEDED(result) ) 
     226    { 
     227        libvlc_exception_t ex; 
     228        libvlc_exception_init(&ex); 
     229 
     230        libvlc_media_player_t *p_md; 
     231        p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); 
     232        if( !libvlc_exception_raised(&ex) ) 
     233        { 
     234            *position = libvlc_media_player_get_position(p_md, &ex); 
     235            libvlc_media_player_release(p_md); 
     236            if( ! libvlc_exception_raised(&ex) ) 
     237            { 
     238                return NOERROR; 
     239            } 
     240        } 
     241        _p_instance->setErrorInfo(IID_IVLCControl, 
     242                     libvlc_exception_get_message(&ex)); 
     243        libvlc_exception_clear(&ex); 
     244        return E_FAIL; 
     245    } 
    200246    return result; 
    201247}; 
     
    204250{ 
    205251    HRESULT result = E_UNEXPECTED; 
    206     if( _p_instance->isRunning() ) 
    207     { 
    208         libvlc_instance_t *p_libvlc; 
    209         result = _p_instance->getVLC(&p_libvlc); 
    210         if( SUCCEEDED(result) ) 
    211         { 
    212             VLC_PositionSet(i_vlc, position); 
    213         } 
     252    libvlc_instance_t* p_libvlc; 
     253    result = _p_instance->getVLC(&p_libvlc); 
     254    if( SUCCEEDED(result) ) 
     255    { 
     256        libvlc_exception_t ex; 
     257        libvlc_exception_init(&ex); 
     258 
     259        libvlc_media_player_t *p_md; 
     260        p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); 
     261        if( ! libvlc_exception_raised(&ex) ) 
     262        { 
     263            libvlc_media_player_set_position(p_md, position, &ex); 
     264            libvlc_media_player_release(p_md); 
     265            if( ! libvlc_exception_raised(&ex) ) 
     266            { 
     267                return NOERROR; 
     268            } 
     269        } 
     270        _p_instance->setErrorInfo(IID_IVLCControl, 
     271                     libvlc_exception_get_message(&ex)); 
     272        libvlc_exception_clear(&ex); 
     273        return E_FAIL; 
    214274    } 
    215275    return result; 
     
    221281        return E_POINTER; 
    222282 
    223     HRESULT result = NOERROR; 
    224     if( _p_instance->isRunning() ) 
    225     { 
    226         libvlc_instance_t *p_libvlc; 
    227         result = _p_instance->getVLC(&p_libvlc); 
    228         if( SUCCEEDED(result) ) 
    229         { 
    230             *seconds = VLC_TimeGet(i_vlc); 
    231         } 
    232     } 
    233     else 
    234         *seconds = _p_instance->getTime(); 
    235  
     283    *seconds = 0; 
     284    libvlc_instance_t* p_libvlc; 
     285    HRESULT result = _p_instance->getVLC(&p_libvlc); 
     286    if( SUCCEEDED(result) ) 
     287    { 
     288        libvlc_exception_t ex; 
     289        libvlc_exception_init(&ex); 
     290 
     291        libvlc_media_player_t *p_md; 
     292        p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); 
     293        if( ! libvlc_exception_raised(&ex) ) 
     294        { 
     295            *seconds = libvlc_media_player_get_time(p_md, &ex); 
     296            libvlc_media_player_release(p_md); 
     297            if( ! libvlc_exception_raised(&ex) ) 
     298            { 
     299                return NOERROR; 
     300            } 
     301        } 
     302        _p_instance->setErrorInfo(IID_IVLCControl, 
     303                     libvlc_exception_get_message(&ex)); 
     304        libvlc_exception_clear(&ex); 
     305        return E_FAIL; 
     306    } 
    236307    return result; 
    237308}; 
     
    239310STDMETHODIMP VLCControl::put_Time(int seconds) 
    240311{ 
     312    /* setTime function of the plugin sets the time. */ 
    241313    _p_instance->setTime(seconds); 
    242  
    243314    return NOERROR; 
    244315}; 
     
    246317STDMETHODIMP VLCControl::shuttle(int seconds) 
    247318{ 
    248     HRESULT result = E_UNEXPECTED; 
    249     if( _p_instance->isRunning() ) 
    250     { 
    251         libvlc_instance_t *p_libvlc; 
    252         result = _p_instance->getVLC(&p_libvlc); 
    253         if( SUCCEEDED(result) ) 
    254         { 
    255             VLC_TimeSet(i_vlc, seconds, true); 
    256         } 
    257     } 
    258     return result; 
     319    libvlc_instance_t* p_libvlc; 
     320    HRESULT result = _p_instance->getVLC(&p_libvlc); 
     321    if( SUCCEEDED(result) ) 
     322    { 
     323        libvlc_exception_t ex; 
     324        libvlc_exception_init(&ex); 
     325 
     326        libvlc_media_player_t *p_md; 
     327        p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); 
     328        if( ! libvlc_exception_raised(&ex) ) 
     329        { 
     330            if( seconds < 0 ) seconds = 0; 
     331            libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex); 
     332            libvlc_media_player_release(p_md); 
     333            if( ! libvlc_exception_raised(&ex) ) 
     334            { 
     335                return NOERROR; 
     336            } 
     337        } 
     338        _p_instance->setErrorInfo(IID_IVLCControl, 
     339                     libvlc_exception_get_message(&ex)); 
     340        libvlc_exception_clear(&ex); 
     341        return E_FAIL; 
     342    } 
     343    return result; 
     344 
    259345}; 
    260346 
     
    287373    if( NULL == seconds ) 
    288374        return E_POINTER; 
    289  
    290     HRESULT result = NOERROR; 
     375    *seconds = 0; 
     376 
     377    libvlc_instance_t* p_libvlc; 
     378    HRESULT result = _p_instance->getVLC(&p_libvlc); 
     379    if( SUCCEEDED(result) ) 
     380    { 
     381        libvlc_exception_t ex; 
     382        libvlc_exception_init(&ex); 
     383 
     384        libvlc_media_player_t *p_md; 
     385        p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); 
     386        if( ! libvlc_exception_raised(&ex) ) 
     387        { 
     388            *seconds = (double)libvlc_media_player_get_length(p_md, &ex); 
     389            libvlc_media_player_release(p_md); 
     390            if( ! libvlc_exception_raised(&ex) ) 
     391            { 
     392                return NOERROR; 
     393            } 
     394        } 
     395        _p_instance->setErrorInfo(IID_IVLCControl, 
     396                     libvlc_exception_get_message(&ex)); 
     397        libvlc_exception_clear(&ex); 
     398        return E_FAIL; 
     399    } 
     400    return result; 
     401 
     402}; 
     403 
     404STDMETHODIMP VLCControl::playFaster(void) 
     405
     406    HRESULT result = E_UNEXPECTED; 
    291407    if( _p_instance->isRunning() ) 
    292408    { 
     
    295411        if( SUCCEEDED(result) ) 
    296412        { 
    297             *seconds = VLC_LengthGet(i_vlc); 
    298             return NOERROR; 
    299         } 
    300     } 
    301     *seconds = 0; 
    302     return result; 
    303 }; 
    304  
    305 STDMETHODIMP VLCControl::playFaster(void) 
     413            VLC_SpeedFaster(i_vlc); 
     414        } 
     415    } 
     416    return result; 
     417}; 
     418 
     419STDMETHODIMP VLCControl::playSlower(void) 
    306420{ 
    307421    HRESULT result = E_UNEXPECTED; 
     
    312426        if( SUCCEEDED(result) ) 
    313427        { 
    314             VLC_SpeedFaster(i_vlc); 
    315         } 
    316     } 
    317     return result; 
    318 }; 
    319  
    320 STDMETHODIMP VLCControl::playSlower(void) 
    321 { 
    322     HRESULT result = E_UNEXPECTED; 
    323     if( _p_instance->isRunning() ) 
    324     { 
    325         libvlc_instance_t *p_libvlc; 
    326         result = _p_instance->getVLC(&p_libvlc); 
    327         if( SUCCEEDED(result) ) 
    328         { 
    329428            VLC_SpeedSlower(i_vlc); 
    330429        } 
     
    350449STDMETHODIMP VLCControl::toggleMute(void) 
    351450{ 
    352     libvlc_instance_t *p_libvlc; 
     451    libvlc_instance_t* p_libvlc; 
    353452    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    354453    if( SUCCEEDED(result) ) 
    355454    { 
    356         VLC_VolumeMute(i_vlc); 
     455        libvlc_exception_t ex; 
     456        libvlc_exception_init(&ex); 
     457 
     458        libvlc_audio_toggle_mute(p_libvlc, &ex); 
     459        if( libvlc_exception_raised(&ex) ) 
     460        { 
     461            _p_instance->setErrorInfo(IID_IVLCControl, 
     462                         libvlc_exception_get_message(&ex)); 
     463            libvlc_exception_clear(&ex); 
     464            return E_FAIL; 
     465        } 
     466        return NOERROR; 
    357467    } 
    358468    return result; 
     
    365475 
    366476    libvlc_instance_t *p_libvlc; 
    367     HRESULT result = _p_instance->getVLC(&p_libvlc); 
     477    HRESULT hr = _p_instance->getVLC(&p_libvlc); 
    368478    if( SUCCEEDED(hr) ) 
    369479    { 
     
    9171027STDMETHODIMP VLCControl::get_PlaylistCount(int *count) 
    9181028{ 
    919     libvlc_instance_t *p_libvlc; 
     1029    if( NULL == count ) 
     1030        return E_POINTER; 
     1031 
     1032    *count = 0; 
     1033    libvlc_instance_t* p_libvlc; 
    9201034    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    9211035    if( SUCCEEDED(result) ) 
    9221036    { 
    923         *count = VLC_PlaylistNumberOfItems(i_vlc); 
     1037        libvlc_exception_t ex; 
     1038        libvlc_exception_init(&ex); 
     1039 
     1040        *count = libvlc_playlist_items_count(p_libvlc, &ex); 
     1041        if( libvlc_exception_raised(&ex) ) 
     1042        { 
     1043            _p_instance->setErrorInfo(IID_IVLCControl, 
     1044                libvlc_exception_get_message(&ex)); 
     1045            libvlc_exception_clear(&ex); 
     1046            return E_FAIL; 
     1047        } 
    9241048        return NOERROR; 
    9251049    } 
    926     *count = 0; 
    9271050    return result; 
    9281051}; 
     
    9301053STDMETHODIMP VLCControl::playlistNext(void) 
    9311054{ 
    932     libvlc_instance_t *p_libvlc; 
     1055    libvlc_instance_t* p_libvlc; 
    9331056    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    9341057    if( SUCCEEDED(result) ) 
    9351058    { 
    936         VLC_PlaylistNext(i_vlc); 
     1059        libvlc_exception_t ex; 
     1060        libvlc_exception_init(&ex); 
     1061 
     1062        libvlc_playlist_next(p_libvlc, &ex); 
     1063        if( libvlc_exception_raised(&ex) ) 
     1064        { 
     1065            _p_instance->setErrorInfo(IID_IVLCControl, 
     1066                libvlc_exception_get_message(&ex)); 
     1067            libvlc_exception_clear(&ex); 
     1068            return E_FAIL; 
     1069        } 
    9371070        return NOERROR; 
    9381071    } 
     
    9421075STDMETHODIMP VLCControl::playlistPrev(void) 
    9431076{ 
    944     libvlc_instance_t *p_libvlc; 
     1077    libvlc_instance_t* p_libvlc; 
    9451078    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    9461079    if( SUCCEEDED(result) ) 
    9471080    { 
    948         VLC_PlaylistPrev(i_vlc); 
     1081        libvlc_exception_t ex; 
     1082        libvlc_exception_init(&ex); 
     1083 
     1084        libvlc_playlist_prev(p_libvlc, &ex); 
     1085        if( libvlc_exception_raised(&ex) ) 
     1086        { 
     1087            _p_instance->setErrorInfo(IID_IVLCControl, 
     1088                libvlc_exception_get_message(&ex)); 
     1089            libvlc_exception_clear(&ex); 
     1090            return E_FAIL; 
     1091        } 
    9491092        return NOERROR; 
    9501093    } 
     
    9541097STDMETHODIMP VLCControl::playlistClear(void) 
    9551098{ 
    956     libvlc_instance_t *p_libvlc; 
     1099    libvlc_instance_t* p_libvlc; 
    9571100    HRESULT result = _p_instance->getVLC(&p_libvlc); 
    9581101    if( SUCCEEDED(result) ) 
    9591102    { 
    960         VLC_PlaylistClear(i_vlc); 
     1103        libvlc_exception_t ex; 
     1104        libvlc_exception_init(&ex); 
     1105 
     1106        libvlc_playlist_clear(p_libvlc, &ex); 
     1107        if( libvlc_exception_raised(&ex) ) 
     1108        { 
     1109            _p_instance->setErrorInfo(IID_IVLCControl, 
     1110                libvlc_exception_get_message(&ex)); 
     1111            libvlc_exception_clear(&ex); 
     1112            return E_FAIL; 
     1113        } 
    9611114        return NOERROR; 
    9621115    } 
     
    9731126    { 
    9741127        *version = BSTRFromCStr(CP_UTF8, versionStr); 
    975  
    976         return NULL == *version ? E_OUTOFMEMORY : NOERROR; 
     1128        return (NULL == *version) ? E_OUTOFMEMORY : NOERROR; 
    9771129    } 
    9781130    *version = NULL;