1 /*****************************************************************************
2 * vlm_slider_manager.cpp : Manage an input slider for a VLM stream
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 "dialogs/vlm/vlm_slider_manager.hpp"
28 #include "dialogs/vlm/vlm_stream.hpp"
29 #include "dialogs/vlm/vlm_streampanel.hpp"
31 /*****************************************************************************
33 *****************************************************************************/
34 VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf,
35 VLMBroadcastStreamPanel *_p_sp ) :
36 SliderManager( _p_intf )
39 _slider = p_sp->p_slider;
41 b_slider_free = VLC_TRUE;
42 time_string = wxU( "0:00:00 / 0:00:00");
45 VLMSliderManager::~VLMSliderManager()
49 /*****************************************************************************
51 *****************************************************************************/
53 void VLMSliderManager::UpdateInput()
55 if( p_sp->GetStream()->p_media->i_instance == 0 )
61 p_input = p_sp->GetStream()->p_media->instance[0]->p_input;
64 void VLMSliderManager::UpdateButtons( vlc_bool_t b_play )
68 p_sp->TogglePlayButton( PLAYING_S );
72 p_sp->TogglePlayButton( PAUSE_S );
76 vlc_bool_t VLMSliderManager::IsShown()
78 return _slider->IsEnabled();
81 void VLMSliderManager::ShowSlider()
86 void VLMSliderManager::HideSlider()
88 _slider->SetValue( 0 );
90 UpdateTime( "0:00:00", "0:00:00" );
93 vlc_bool_t VLMSliderManager::IsFree()
98 vlc_bool_t VLMSliderManager::IsPlaying()
100 return VLC_TRUE; /* Is it really useful ? */
103 void VLMSliderManager::UpdateTime( char *psz_time, char *psz_total )
105 time_string = wxU(psz_time) + wxString(wxT(" / ") ) +wxU(psz_total) ;
109 void VLMSliderManager::ProcessUpdate( wxScrollEvent &event )
113 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
114 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
117 if( i_slider_pos != event.GetPosition() && p_input )
120 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
122 var_Set( p_input, "position", pos );
126 b_slider_free = VLC_TRUE;
130 b_slider_free = VLC_FALSE;
134 /* Update stream date */
135 char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
138 i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
139 secstotimestr( psz_total, i_seconds );
141 i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );
142 secstotimestr( psz_time, i_seconds );
144 time_string = wxU(psz_time) + wxString(wxT(" / ") ) +wxU(psz_total) ;