void libvlc_media_player_set_pause( libvlc_media_player_t *p_mi, int paused ) { input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi ); if( !p_input_thread ) return; libvlc_state_t state = libvlc_media_player_get_state( p_mi ); if( state == libvlc_Playing || state == libvlc_Buffering ) { if( paused ) { if( libvlc_media_player_can_pause( p_mi ) ) input_Control( p_input_thread, INPUT_SET_STATE, PAUSE_S ); else input_Stop( p_input_thread, true ); } } else { if( !paused ) input_Control( p_input_thread, INPUT_SET_STATE, PLAYING_S ); } vlc_object_release( p_input_thread ); }
void VlcVideoWidget::Pause() { if (!vlcPlayer_) return; if (libvlc_media_player_can_pause(vlcPlayer_)) libvlc_media_player_pause(vlcPlayer_); }
void VlcMediaPlayer::pause() { if (!_vlcMediaPlayer) return; if (libvlc_media_player_can_pause(_vlcMediaPlayer)) libvlc_media_player_pause(_vlcMediaPlayer); VlcError::errmsg(); }
bool VLCVideoWrapper::pause(void) { // check if the player can be paused if(libvlc_media_player_can_pause(_MediaPlayer)) { // can pause it? do it libvlc_media_player_pause(_MediaPlayer); // error checking of course checkVLCError("pausing"); } if(isPaused()) { producePaused(); return true; } else { return false; } }
bool VLCVideoWrapper::open(const std::string& ThePath, Window* const TheWindow) { bool errorOpening(false); //BoostPath PluginsDirPath("/Applications/VLC.app/Contents/MacOS/modules"); BoostPath PluginsDirPath("/Applications/VLC-1.1.7.app/Contents/MacOS/modules"); std::vector<std::string> VLCArguments; VLCArguments.push_back("-I"); VLCArguments.push_back("dummy"); /* no interface */ VLCArguments.push_back(std::string("--plugin-path=") + PluginsDirPath.string()); //VLCArguments.push_back("--no-audio"); [> we don't want audio <] VLCArguments.push_back("--verbose=0"); /* show only errors */ VLCArguments.push_back("--no-media-library");/* don't want that */ VLCArguments.push_back("--services-discovery=");/* don't want that */ VLCArguments.push_back("--no-video-title-show");/* don't want that */ VLCArguments.push_back("--no-stats");/* don't want that */ VLCArguments.push_back("--ignore-config"); /* don't use/overwrite the config */ VLCArguments.push_back("--no-sub-autodetect");/* don't want subtitles */ VLCArguments.push_back("--control=");/* don't want interface (again) */ VLCArguments.push_back("--no-disable-screensaver");/* don't want that */ // libvlc settings const char** args = new const char*[VLCArguments.size()]; for(UInt32 i(0) ; i<VLCArguments.size() ; ++i) { args[i] = VLCArguments[i].c_str(); } /* * Initialise libVLC */ UInt32 nargs = VLCArguments.size(); _VLCInstance = libvlc_new( nargs, args ); if(_VLCInstance == NULL) { checkVLCError("creating new vlc instance"); return false; } delete [] args; // creates vlc struct holding data to the video file libvlc_media_t *TheMedia = libvlc_media_new_path( _VLCInstance, ThePath.c_str() ); checkVLCError("initializing media file"); // initialize a temporary media player so we can get height and width before // adding the vmem options to TheMedia libvlc_media_player_t * tempMediaPlayer = libvlc_media_player_new_from_media( TheMedia ); unsigned Width(200), Height(200); libvlc_video_set_callbacks(tempMediaPlayer, lock, unlock, display, &_VideoMemContext); _VideoMemContext._pixels = ( UInt8* )malloc( ( sizeof( *( _VideoMemContext._pixels ) ) * Width * Height ) * 4 ); libvlc_video_set_format(tempMediaPlayer, "RV24", Width, Height, Width * 3); //Release the media file libvlc_media_release( TheMedia ); libvlc_media_player_play( tempMediaPlayer ); checkVLCError("playing the media"); libvlc_state_t currentState; do { currentState = libvlc_media_player_get_state(tempMediaPlayer); checkVLCError("getting state"); } while(currentState != libvlc_Playing); int VLCResult; do { VLCResult = libvlc_video_get_size(tempMediaPlayer, 0, &Width, &Height); } while(VLCResult != 0); checkVLCError("getting size"); libvlc_media_player_stop( tempMediaPlayer ); libvlc_media_player_release(tempMediaPlayer);// releases media currently in use //Now that we have the size initialize the media again TheMedia = libvlc_media_new_path( _VLCInstance, ThePath.c_str() ); checkVLCError("initializing media file"); // initialize the media player _MediaPlayer = libvlc_media_player_new_from_media( TheMedia ); checkVLCError("initializing media player"); //Release the media file libvlc_media_release( TheMedia ); #ifdef __APPLE__ //set agl handle (if TheWindow is pointing to a carbon window) if (TheWindow->getType().isDerivedFrom(CarbonWindow::getClassType())) { HIWindowRef windowRef = aglGetWindowRef(dynamic_cast<CarbonWindow* const>(TheWindow)->getContext()); HIViewRef contentView = 0; GetRootControl(windowRef, &contentView); //uint32_t aglHandler = CarbonWindowPtr::dcast(TheWindow)->winId(); libvlc_media_player_set_agl (_MediaPlayer, reinterpret_cast<uint32_t>(contentView) ); checkVLCError("attaching media player to carbon window"); } #endif #ifdef WIN32 if (TheWindow->getType().isDerivedFrom(WIN32Window::getClassType())) { libvlc_media_player_set_hwnd (_MediaPlayer, dynamic_cast<WIN32Window* const>(TheWindow)->getHwnd() ); checkVLCError("attaching media player to WIN32 window"); } #endif #ifdef __linux if (TheWindow->getType().isDerivedFrom(XWindow::getClassType())) { libvlc_media_player_set_xwindow (_MediaPlayer, dynamic_cast<XWindow* const>(TheWindow)->getDisplay() ); checkVLCError("attaching media player to Xwindow"); } #endif libvlc_video_set_callbacks(_MediaPlayer, lock, unlock, display, &_VideoMemContext); _VideoMemContext._pixels = ( UInt8* )malloc( ( sizeof( *( _VideoMemContext._pixels ) ) * Width * Height ) * 4 ); libvlc_video_set_format(_MediaPlayer, "RV24", Width, Height, Width * 3); //Start playing the video libvlc_media_player_play( _MediaPlayer ); checkVLCError("playing the media"); do { currentState = libvlc_media_player_get_state(_MediaPlayer); checkVLCError("getting state"); } while(currentState != libvlc_Playing); clock_t endwait; endwait = clock () + 2 * CLOCKS_PER_SEC ; while (clock() < endwait) {} _Initialized = true; // check if the player can be paused if(libvlc_media_player_can_pause(_MediaPlayer)) { // can pause it? do it libvlc_media_player_pause(_MediaPlayer); // error checking of course checkVLCError("pausing media player"); libvlc_media_player_set_position( _MediaPlayer, 0.0f ); checkVLCError("setting position during player initialization"); } return errorOpening; }