1 /*****************************************************************************
2 * input_manager.cpp : Manage an input and interact with its GUI elements
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Ilkka Ollakka <ileoo@videolan.org>
9 * Jean-Baptiste <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include "input_manager.hpp"
34 #include <QApplication>
38 static int ItemChanged( vlc_object_t *, const char *,
39 vlc_value_t, vlc_value_t, void * );
40 static int PLItemChanged( vlc_object_t *, const char *,
41 vlc_value_t, vlc_value_t, void * );
42 static int PLItemAppended( vlc_object_t *, const char *,
43 vlc_value_t, vlc_value_t, void * );
44 static int PLItemRemoved( vlc_object_t *, const char *,
45 vlc_value_t, vlc_value_t, void * );
46 static int VolumeChanged( vlc_object_t *, const char *,
47 vlc_value_t, vlc_value_t, void * );
49 static int InputEvent( vlc_object_t *, const char *,
50 vlc_value_t, vlc_value_t, void * );
51 static int VbiEvent( vlc_object_t *, const char *,
52 vlc_value_t, vlc_value_t, void * );
55 /**********************************************************************
56 * InputManager implementation
57 **********************************************************************
58 * The Input Manager can be the main one around the playlist
59 * But can also be used for VLM dialog or similar
60 **********************************************************************/
62 InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
63 QObject( parent ), p_intf( _p_intf )
65 i_old_playing_status = END_S;
74 f_cache = -1.; /* impossible initial value, different from all */
77 InputManager::~InputManager()
82 /* Define the Input used.
83 Add the callbacks on input
84 p_input is held once here */
85 void InputManager::setInput( input_thread_t *_p_input )
89 if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) )
91 msg_Dbg( p_intf, "IM: Setting an input" );
92 vlc_object_hold( p_input );
93 emit statusChanged( PLAYING_S );
100 p_item = input_GetItem( p_input );
106 emit rateChanged( INPUT_RATE_DEFAULT );
110 /* delete Input if it ever existed.
111 Delete the callbacls on input
112 p_input is released once here */
113 void InputManager::delInput()
115 if( !p_input ) return;
116 msg_Dbg( p_intf, "IM: Deleting the input" );
119 i_old_playing_status = END_S;
127 vlc_object_release( p_input );
130 emit positionUpdated( -1.0, 0 ,0 );
131 emit rateChanged( INPUT_RATE_DEFAULT ); /* TODO: Do we want this ? */
132 emit nameChanged( "" );
133 emit chapterChanged( 0 );
134 emit titleChanged( 0 );
135 emit statusChanged( END_S );
137 emit teletextPossible( false );
138 emit AtoBchanged( false, false );
139 emit voutChanged( false );
140 emit voutListChanged( NULL, 0 );
142 /* Reset all InfoPanels but stats */
143 emit artChanged( NULL );
144 emit infoChanged( NULL );
145 emit currentMetaChanged( (input_item_t *)NULL );
147 emit encryptionChanged( false );
148 emit recordingStateChanged( false );
151 /* Convert the event from the callbacks in actions */
152 void InputManager::customEvent( QEvent *event )
154 int i_type = event->type();
155 IMEvent *ple = static_cast<IMEvent *>(event);
157 if( i_type == ItemChanged_Type )
158 UpdateMeta( ple->p_item );
166 case PositionUpdate_Type:
169 case StatisticsUpdate_Type:
172 case ItemChanged_Type:
173 /* Ignore ItemChanged_Type event that does not apply to our input */
174 if( p_item == ple->p_item )
179 /* Update duration of file */
182 case ItemStateChanged_Type:
183 // TODO: Fusion with above state
186 // UpdateNavigation(); This shouldn't be useful now
187 // UpdateTeletext(); Same
189 case NameChanged_Type:
192 case MetaChanged_Type:
194 UpdateName(); /* Needed for NowPlaying */
195 UpdateArt(); /* Art is part of meta in the core */
197 case InfoChanged_Type:
200 case ItemTitleChanged_Type:
202 UpdateName(); /* Display the name of the Chapter, if exists */
204 case ItemRateChanged_Type:
207 case ItemEsChanged_Type:
209 // We don't do anything ES related. Why ?
211 case ItemTeletextChanged_Type:
214 case InterfaceVoutUpdate_Type:
217 case SynchroChanged_Type:
218 emit synchroChanged();
220 case CachingEvent_Type:
223 case BookmarksChanged_Type:
224 emit bookmarksChanged();
226 case InterfaceAoutUpdate_Type:
229 case RecordingEvent_Type:
232 case ProgramChanged_Type:
233 UpdateProgramEvent();
236 msg_Warn( p_intf, "This shouldn't happen: %i", i_type );
241 /* Add the callbacks on Input. Self explanatory */
242 inline void InputManager::addCallbacks()
244 var_AddCallback( p_input, "intf-event", InputEvent, this );
247 /* Delete the callbacks on Input. Self explanatory */
248 inline void InputManager::delCallbacks()
250 var_DelCallback( p_input, "intf-event", InputEvent, this );
253 /* Static callbacks for IM */
254 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
255 vlc_value_t oldval, vlc_value_t newval, void *param )
257 InputManager *im = (InputManager*)param;
258 input_item_t *p_item = static_cast<input_item_t *>(newval.p_address);
260 IMEvent *event = new IMEvent( ItemChanged_Type, p_item );
261 QApplication::postEvent( im, event );
265 static int InputEvent( vlc_object_t *p_this, const char *,
266 vlc_value_t, vlc_value_t newval, void *param )
268 InputManager *im = (InputManager*)param;
271 switch( newval.i_int )
273 case INPUT_EVENT_STATE:
274 event = new IMEvent( ItemStateChanged_Type );
276 case INPUT_EVENT_RATE:
277 event = new IMEvent( ItemRateChanged_Type );
279 case INPUT_EVENT_POSITION:
280 //case INPUT_EVENT_LENGTH:
281 event = new IMEvent( PositionUpdate_Type );
284 case INPUT_EVENT_TITLE:
285 case INPUT_EVENT_CHAPTER:
286 event = new IMEvent( ItemTitleChanged_Type );
290 event = new IMEvent( ItemEsChanged_Type );
292 case INPUT_EVENT_TELETEXT:
293 event = new IMEvent( ItemTeletextChanged_Type );
296 case INPUT_EVENT_STATISTICS:
297 event = new IMEvent( StatisticsUpdate_Type );
300 case INPUT_EVENT_VOUT:
301 event = new IMEvent( InterfaceVoutUpdate_Type );
303 case INPUT_EVENT_AOUT:
304 event = new IMEvent( InterfaceAoutUpdate_Type );
307 case INPUT_EVENT_ITEM_META: /* Codec MetaData + Art */
308 event = new IMEvent( MetaChanged_Type );
310 case INPUT_EVENT_ITEM_INFO: /* Codec Info */
311 event = new IMEvent( InfoChanged_Type );
313 case INPUT_EVENT_ITEM_NAME:
314 event = new IMEvent( NameChanged_Type );
317 case INPUT_EVENT_AUDIO_DELAY:
318 case INPUT_EVENT_SUBTITLE_DELAY:
319 event = new IMEvent( SynchroChanged_Type );
322 case INPUT_EVENT_CACHE:
323 event = new IMEvent( CachingEvent_Type );
326 case INPUT_EVENT_BOOKMARK:
327 event = new IMEvent( BookmarksChanged_Type );
330 case INPUT_EVENT_RECORD:
331 event = new IMEvent( RecordingEvent_Type );
334 case INPUT_EVENT_PROGRAM:
335 /* This is for PID changes */
336 event = new IMEvent( ProgramChanged_Type );
339 case INPUT_EVENT_SIGNAL:
340 /* This is for capture-card signals */
341 /* event = new IMEvent( SignalChanged_Type );
349 QApplication::postEvent( im, event );
353 static int VbiEvent( vlc_object_t *, const char *,
354 vlc_value_t, vlc_value_t, void *param )
356 InputManager *im = (InputManager*)param;
357 IMEvent *event = new IMEvent( ItemTeletextChanged_Type );
359 QApplication::postEvent( im, event );
363 void InputManager::UpdatePosition()
365 /* Update position */
366 int i_length, i_time; /* Int is enough, since we store seconds */
368 i_length = var_GetTime( p_input , "length" ) / 1000000;
369 i_time = var_GetTime( p_input , "time") / 1000000;
370 f_pos = var_GetFloat( p_input , "position" );
371 emit positionUpdated( f_pos, i_time, i_length );
374 void InputManager::UpdateNavigation()
376 /* Update navigation status */
377 vlc_value_t val; val.i_int = 0;
380 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
384 emit titleChanged( true );
385 msg_Dbg( p_intf, "Title %i", val.i_int );
386 /* p_input != NULL since val.i_int != 0 */
388 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
389 emit chapterChanged( (val.i_int > 0) );
390 msg_Dbg( p_intf, "Chapter: %i", val.i_int );
393 emit titleChanged( false );
396 void InputManager::UpdateStatus()
398 /* Update playing status */
399 int state = var_GetInteger( p_input, "state" );
400 if( i_old_playing_status != state )
402 i_old_playing_status = state;
403 emit statusChanged( state );
407 void InputManager::UpdateRate()
410 int i_new_rate = var_GetInteger( p_input, "rate");
411 if( i_new_rate != i_rate )
415 emit rateChanged( i_rate );
419 void InputManager::UpdateName()
421 /* Update text, name and nowplaying */
424 /* Try to get the Title, then the Name */
425 char *psz_name = input_item_GetTitleFbName( input_GetItem( p_input ) );
427 /* Try to get the nowplaying */
428 char *psz_nowplaying =
429 input_item_GetNowPlaying( input_GetItem( p_input ) );
430 if( !EMPTY_STR( psz_nowplaying ) )
432 text.sprintf( "%s - %s", psz_nowplaying, psz_name );
434 else /* Do it ourself */
436 char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
438 if( !EMPTY_STR( psz_artist ) )
439 text.sprintf( "%s - %s", psz_artist, psz_name );
441 text.sprintf( "%s", psz_name );
445 /* Free everything */
447 free( psz_nowplaying );
449 /* If we have Nothing */
452 psz_name = input_item_GetURI( input_GetItem( p_input ) );
453 text.sprintf( "%s", psz_name );
454 text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 );
458 if( oldName != text )
460 emit nameChanged( text );
465 bool InputManager::hasAudio()
470 var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
471 return val.i_int > 0;
476 void InputManager::UpdateTeletext()
480 const bool b_enabled = var_CountChoices( p_input, "teletext-es" ) > 0;
481 const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );
483 /* Teletext is possible. Show the buttons */
484 emit teletextPossible( b_enabled );
486 /* If Teletext is selected */
487 if( b_enabled && i_teletext_es >= 0 )
489 /* Then, find the current page */
491 bool b_transparent = false;
493 vlc_object_t *p_vbi = (vlc_object_t *)
494 vlc_object_find_name( p_input, "zvbi", FIND_CHILD );
498 /* We deleted it (if not here, it does not harm), because
499 * var_AddCallback will silently add a duplicated one */
500 var_DelCallback( p_vbi, "vbi-page", VbiEvent, this );
501 /* This callback is not remove explicitly, but interfaces
502 * are guaranted to outlive input */
503 var_AddCallback( p_vbi, "vbi-page", VbiEvent, this );
505 i_page = var_GetInteger( p_vbi, "vbi-page" );
506 b_transparent = !var_GetBool( p_vbi, "vbi-opaque" );
507 vlc_object_release( p_vbi );
509 emit newTelexPageSet( i_page );
510 emit teletextTransparencyActivated( b_transparent );
513 emit teletextActivated( b_enabled && i_teletext_es >= 0 );
517 emit teletextActivated( false );
518 emit teletextPossible( false );
522 void InputManager::UpdateVout()
526 /* Get current vout lists from input */
528 vout_thread_t **pp_vout;
529 if( input_Control( p_input, INPUT_GET_VOUTS, &pp_vout, &i_vout ) )
536 emit voutListChanged( pp_vout, i_vout );
539 bool b_old_video = b_video;
540 b_video = i_vout > 0;
541 if( !!b_old_video != !!b_video )
542 emit voutChanged( b_video );
544 /* Release the vout list */
545 for( int i = 0; i < i_vout; i++ )
546 vlc_object_release( (vlc_object_t*)pp_vout[i] );
550 void InputManager::UpdateAout()
557 void InputManager::UpdateCaching()
559 if(!hasInput()) return;
561 float f_newCache = var_GetFloat ( p_input, "cache" );
562 if( f_newCache != f_cache )
564 f_cache = f_newCache;
566 emit cachingChanged( f_cache );
570 void InputManager::requestArtUpdate()
574 playlist_t *p_playlist = pl_Hold( p_intf );
575 playlist_AskForArtEnqueue( p_playlist, input_GetItem( p_input ), pl_Unlocked );
576 pl_Release( p_intf );
580 /* No input will signal the cover art to update,
581 * let's do it ourself */
586 void InputManager::UpdateArt()
592 char *psz_art = input_item_GetArtURL( input_GetItem( p_input ) );
593 if( psz_art && !strncmp( psz_art, "file://", 7 ) &&
594 decode_URI( psz_art + 7 ) )
596 url = qfu( psz_art + 8 ); // Remove extra / starting on Win32.
598 url = qfu( psz_art + 7 );
602 url = url.replace( "file://", "" );
603 /* Taglib seems to define a attachment://, It won't work yet */
604 url = url.replace( "attachment://", "" );
607 /* Update Art meta */
608 emit artChanged( url );
611 inline void InputManager::UpdateStats()
613 emit statisticsUpdated( input_GetItem( p_input ) );
616 inline void InputManager::UpdateMeta( input_item_t *p_item )
618 emit metaChanged( p_item );
621 inline void InputManager::UpdateMeta()
623 emit currentMetaChanged( input_GetItem( p_input ) );
626 inline void InputManager::UpdateInfo()
628 emit infoChanged( input_GetItem( p_input ) );
631 void InputManager::UpdateRecord()
635 emit recordingStateChanged( var_GetBool( p_input, "record" ) );
639 void InputManager::UpdateProgramEvent()
643 bool b_scrambled = var_GetBool( p_input, "program-scrambled" );
644 emit encryptionChanged( b_scrambled );
648 /* User update of the slider */
649 void InputManager::sliderUpdate( float new_pos )
652 var_SetFloat( p_input, "position", new_pos );
655 /* User togglePlayPause */
656 void InputManager::togglePlayPause()
660 int state = var_GetInteger( p_input, "state" );
661 state = ( state != PLAYING_S ) ? PLAYING_S : PAUSE_S;
662 var_SetInteger( p_input, "state", state );
663 emit statusChanged( state );
667 void InputManager::sectionPrev()
671 int i_type = var_Type( p_input, "next-chapter" );
672 var_TriggerCallback( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
673 "prev-chapter":"prev-title" );
677 void InputManager::sectionNext()
681 int i_type = var_Type( p_input, "next-chapter" );
682 var_TriggerCallback( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
683 "next-chapter":"next-title" );
687 void InputManager::sectionMenu()
691 vlc_value_t val, text;
693 if( var_Change( p_input, "title 0", VLC_VAR_GETLIST, &val, &text ) < 0 )
696 /* XXX is it "Root" or "Title" we want here ?" (set 0 by default) */
698 for( int i = 0; i < val.p_list->i_count; i++ )
700 if( !strcmp( text.p_list->p_values[i].psz_string, "Title" ) )
703 var_FreeList( &val, &text );
705 var_SetInteger( p_input, "title 0", root );
713 /* Set a new Teletext Page */
714 void InputManager::telexSetPage( int page )
718 const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );
720 if( i_teletext_es >= 0 )
722 vlc_object_t *p_vbi = (vlc_object_t *) vlc_object_find_name( p_input,
723 "zvbi", FIND_CHILD );
726 var_SetInteger( p_vbi, "vbi-page", page );
727 vlc_object_release( p_vbi );
728 emit newTelexPageSet( page );
734 /* Set the transparency on teletext */
735 void InputManager::telexSetTransparency( bool b_transparentTelextext )
739 vlc_object_t *p_vbi = (vlc_object_t *) vlc_object_find_name( p_input,
740 "zvbi", FIND_CHILD );
743 var_SetBool( p_vbi, "vbi-opaque", !b_transparentTelextext );
744 vlc_object_release( p_vbi );
745 emit teletextTransparencyActivated( b_transparentTelextext );
750 void InputManager::activateTeletext( bool b_enable )
754 if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETLIST, &list, &text ) )
756 if( list.p_list->i_count > 0 )
758 /* Prefer the page 100 if it is present */
760 for( i = 0; i < text.p_list->i_count; i++ )
762 /* The description is the page number as a string */
763 const char *psz_page = text.p_list->p_values[i].psz_string;
764 if( psz_page && !strcmp( psz_page, "100" ) )
767 if( i >= list.p_list->i_count )
769 var_SetInteger( p_input, "spu-es", b_enable ? list.p_list->p_values[i].i_int : -1 );
771 var_FreeList( &list, &text );
775 void InputManager::reverse()
779 int i_rate = var_GetInteger( p_input, "rate" );
780 var_SetInteger( p_input, "rate", -i_rate );
784 void InputManager::slower()
787 var_TriggerCallback( p_input, "rate-slower" );
790 void InputManager::faster()
793 var_TriggerCallback( p_input, "rate-faster" );
796 void InputManager::littlefaster()
798 var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_RATE_FASTER_FINE );
801 void InputManager::littleslower()
803 var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_RATE_SLOWER_FINE );
806 void InputManager::normalRate()
809 var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
812 void InputManager::setRate( int new_rate )
815 var_SetInteger( p_input, "rate", new_rate );
818 void InputManager::jumpFwd()
820 int i_interval = config_GetInt( p_input, "short-jump-size" );
823 mtime_t val = (mtime_t)(i_interval) * 1000000L;
824 var_SetTime( p_input, "time-offset", val );
828 void InputManager::jumpBwd()
830 int i_interval = config_GetInt( p_input, "short-jump-size" );
833 mtime_t val = -1 *(mtime_t)(i_interval) * 1000000L;
834 var_SetTime( p_input, "time-offset", val );
838 void InputManager::setAtoB()
842 timeA = var_GetTime( THEMIM->getInput(), "time" );
846 timeB = var_GetTime( THEMIM->getInput(), "time" );
847 var_SetTime( THEMIM->getInput(), "time" , timeA );
848 CONNECT( this, positionUpdated( float, int, int ),
849 this, AtoBLoop( float, int, int ) );
855 disconnect( this, SIGNAL( positionUpdated( float, int, int ) ),
856 this, SLOT( AtoBLoop( float, int, int ) ) );
858 emit AtoBchanged( (timeA != 0 ), (timeB != 0 ) );
861 /* Function called regularly when in an AtoB loop */
862 void InputManager::AtoBLoop( float, int i_time, int )
866 if( ( i_time >= (int)( timeB/1000000 ) )
867 || ( i_time < (int)( timeA/1000000 ) ) )
868 var_SetTime( THEMIM->getInput(), "time" , timeA );
872 /**********************************************************************
873 * MainInputManager implementation. Wrap an input manager and
874 * take care of updating the main playlist input.
875 * Used in the main playlist Dialog
876 **********************************************************************/
877 MainInputManager * MainInputManager::instance = NULL;
879 MainInputManager::MainInputManager( intf_thread_t *_p_intf )
880 : QObject(NULL), p_intf( _p_intf )
883 im = new InputManager( this, p_intf );
885 var_AddCallback( THEPL, "item-change", ItemChanged, im );
886 var_AddCallback( THEPL, "item-current", PLItemChanged, this );
887 var_AddCallback( THEPL, "activity", PLItemChanged, this );
888 var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this );
889 var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
891 var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
893 /* Warn our embedded IM about input changes */
894 CONNECT( this, inputChanged( input_thread_t * ),
895 im, setInput( input_thread_t * ) );
897 /* emit check if playlist has already started playing */
898 input_thread_t *p_input = playlist_CurrentInput( THEPL );
901 input_item_t *p_item = input_GetItem( p_input );
904 IMEvent *event = new IMEvent( ItemChanged_Type, p_item );
905 customEvent( event );
908 vlc_object_release( p_input );
912 MainInputManager::~MainInputManager()
916 emit inputChanged( NULL );
917 var_DelCallback( p_input, "state", PLItemChanged, this );
918 vlc_object_release( p_input );
921 var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
923 var_DelCallback( THEPL, "activity", PLItemChanged, this );
924 var_DelCallback( THEPL, "item-change", ItemChanged, im );
926 var_DelCallback( THEPL, "item-current", PLItemChanged, this );
927 var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this );
928 var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
931 vout_thread_t* MainInputManager::getVout()
933 return p_input ? input_GetVout( p_input ) : NULL;
936 aout_instance_t * MainInputManager::getAout()
938 return p_input ? input_GetAout( p_input ) : NULL;
941 void MainInputManager::customEvent( QEvent *event )
943 int type = event->type();
947 // msg_Dbg( p_intf, "New MainIM Event of type: %i", type );
950 case VolumeChanged_Type:
951 emit volumeChanged();
953 case PLItemAppended_Type:
954 plEv = static_cast<PLEvent*>( event );
955 emit playlistItemAppended( plEv->i_item, plEv->i_parent );
957 case PLItemRemoved_Type:
958 plEv = static_cast<PLEvent*>( event );
959 emit playlistItemRemoved( plEv->i_item );
962 if( type != ItemChanged_Type ) return;
965 /* Should be PLItemChanged Event */
966 if( !p_intf->p_sys->b_isDialogProvider )
968 if( p_input && ( p_input->b_dead || !vlc_object_alive (p_input) ) )
970 emit inputChanged( p_input );
971 var_DelCallback( p_input, "state", PLItemChanged, this );
972 vlc_object_release( p_input );
979 p_input = playlist_CurrentInput(THEPL);
982 var_AddCallback( p_input, "state", PLItemChanged, this );
983 emit inputChanged( p_input );
989 /* remove previous stored p_input */
992 vlc_object_release( p_input );
995 /* we are working as a dialogs provider */
996 playlist_t *p_playlist = pl_Hold( p_intf );
997 p_input = playlist_CurrentInput( p_playlist );
1000 emit inputChanged( p_input );
1002 pl_Release( p_intf );
1006 /* Playlist Control functions */
1007 void MainInputManager::stop()
1009 playlist_Stop( THEPL );
1012 void MainInputManager::next()
1014 playlist_Next( THEPL );
1017 void MainInputManager::prev()
1019 playlist_Prev( THEPL );
1022 void MainInputManager::togglePlayPause()
1024 /* No input, play */
1026 playlist_Play( THEPL );
1028 getIM()->togglePlayPause();
1031 void MainInputManager::activatePlayQuit( bool b_exit )
1033 var_SetBool( THEPL, "play-and-exit", b_exit );
1036 /* Static callbacks for MIM */
1037 static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
1038 vlc_value_t oldval, vlc_value_t, void *param )
1040 MainInputManager *mim = (MainInputManager*)param;
1042 IMEvent *event = new IMEvent( ItemChanged_Type );
1043 QApplication::postEvent( mim, event );
1047 static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
1048 vlc_value_t oldval, vlc_value_t newval, void *param )
1050 MainInputManager *mim = (MainInputManager*)param;
1052 IMEvent *event = new IMEvent( VolumeChanged_Type );
1053 QApplication::postEvent( mim, event );
1057 static int PLItemAppended
1058 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
1060 MainInputManager *mim = static_cast<MainInputManager*>(data);
1061 playlist_add_t *p_add = static_cast<playlist_add_t*>( cur.p_address );
1063 PLEvent *event = new PLEvent( PLItemAppended_Type, p_add->i_item, p_add->i_node );
1064 QApplication::postEvent( mim, event );
1067 static int PLItemRemoved
1068 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
1070 MainInputManager *mim = static_cast<MainInputManager*>(data);
1072 PLEvent *event = new PLEvent( PLItemRemoved_Type, cur.i_int, 0 );
1073 QApplication::postEvent( mim, event );