1 /*****************************************************************************
2 * slider_manager.cpp : Manage an input slider
3 *****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
5 * $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
38 #include "wxwidgets.hpp"
40 #include "slider_manager.hpp"
42 /*****************************************************************************
44 *****************************************************************************/
45 SliderManager::SliderManager( intf_thread_t *_p_intf )
49 i_old_playing_status = PAUSE_S;
52 SliderManager::~SliderManager()
54 vlc_mutex_lock( &p_intf->change_lock );
55 if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
56 p_intf->p_sys->p_input = NULL;
57 vlc_mutex_unlock( &p_intf->change_lock );
60 /*****************************************************************************
62 *****************************************************************************/
63 void SliderManager::Update()
65 /* Update the input */
71 _slider->SetValue( 0 );
74 UpdateButtons( VLC_TRUE );
76 i_old_playing_status = PLAYING_S;
79 else if( p_input->b_dead )
84 UpdateButtons( VLC_FALSE );
86 i_old_playing_status = PAUSE_S;
88 vlc_object_release( p_input );
102 /* Really manage the slider */
103 var_Get( p_input, "position", &pos );
107 if( pos.f_float > 0.0 && ! IsShown() )
111 else if( pos.f_float <= 0.0 )
116 if( IsPlaying() && IsShown() )
118 /* Update the slider if the user isn't dragging it. */
121 char psz_time[ MSTRTIME_MAX_SIZE ];
122 char psz_total[ MSTRTIME_MAX_SIZE ];
126 /* Update the value */
127 if( pos.f_float >= 0.0 )
129 i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
131 _slider->SetValue( i_slider_pos );
133 var_Get( p_input, "time", &time );
134 i_seconds = time.i_time / 1000000;
135 secstotimestr ( psz_time, i_seconds );
137 var_Get( p_input, "length", &time );
138 i_seconds = time.i_time / 1000000;
139 secstotimestr ( psz_total, i_seconds );
141 UpdateTime( psz_time, psz_total );
142 // p_main_interface->statusbar->SetStatusText(
143 // wxU(psz_time) + wxString(wxT(" / ")) +
144 // wxU(psz_total), 0 );