]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/vlm/vlm_slider_manager.cpp
p( vlc.getInterfaces().getInterface( "wxwidgets" ).isBroken() ) = 1/2
[vlc] / modules / gui / wxwidgets / dialogs / vlm / vlm_slider_manager.cpp
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 $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "dialogs/vlm/vlm_slider_manager.hpp"
28 #include "dialogs/vlm/vlm_stream.hpp"
29 #include "dialogs/vlm/vlm_streampanel.hpp"
30
31 /*****************************************************************************
32  * Constructor.
33  *****************************************************************************/
34 VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf,
35                                     VLMBroadcastStreamPanel *_p_sp ) :
36         SliderManager( _p_intf )
37 {
38     p_sp = _p_sp;
39     _slider = p_sp->p_slider;
40
41     b_slider_free = VLC_TRUE;
42     time_string = wxU( "0:00:00 / 0:00:00");
43 }
44
45 VLMSliderManager::~VLMSliderManager()
46 {
47 }
48
49 /*****************************************************************************
50  * Private methods.
51  *****************************************************************************/
52
53 void VLMSliderManager::UpdateInput()
54 {
55     if( p_sp->GetStream()->p_media->i_instance == 0 )
56     {
57         p_input = NULL;
58         return;
59     }
60     /** FIXME !! */
61     p_input = p_sp->GetStream()->p_media->instance[0]->p_input;
62 }
63
64 void VLMSliderManager::UpdateButtons( vlc_bool_t b_play )
65 {
66     if( b_play )
67     {
68         p_sp->TogglePlayButton( PLAYING_S );
69     }
70     else
71     {
72         p_sp->TogglePlayButton( PAUSE_S );
73     }
74 }
75
76 vlc_bool_t VLMSliderManager::IsShown()
77 {
78     return _slider->IsEnabled();
79 }
80
81 void VLMSliderManager::ShowSlider()
82 {
83     _slider->Enable();
84 }
85
86 void VLMSliderManager::HideSlider()
87 {
88     _slider->SetValue( 0 );
89     _slider->Disable();
90     UpdateTime( "0:00:00", "0:00:00" );
91 }
92
93 vlc_bool_t VLMSliderManager::IsFree()
94 {
95     return b_slider_free;
96 }
97
98 vlc_bool_t VLMSliderManager::IsPlaying()
99 {
100     return VLC_TRUE; /* Is it really useful ? */
101 }
102
103 void VLMSliderManager::UpdateTime( char *psz_time, char *psz_total )
104 {
105     time_string = wxU(psz_time) + wxString(wxT(" / ") ) +wxU(psz_total) ;
106 }
107
108
109 void VLMSliderManager::ProcessUpdate( wxScrollEvent &event )
110 {
111
112 #ifdef WIN32
113     if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
114         || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
115     {
116 #endif
117         if( i_slider_pos != event.GetPosition() && p_input )
118         {
119             vlc_value_t pos;
120             pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
121
122             var_Set( p_input, "position", pos );
123         }
124
125 #ifdef WIN32
126         b_slider_free = VLC_TRUE;
127     }
128     else
129     {
130         b_slider_free = VLC_FALSE;
131
132         if( p_input )
133         {
134             /* Update stream date */
135             char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
136             mtime_t i_seconds;
137
138             i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
139             secstotimestr( psz_total, i_seconds );
140
141             i_seconds = var_GetTime( p_input, "time" ) /   I64C(1000000 );
142             secstotimestr( psz_time, i_seconds );
143
144             time_string = wxU(psz_time) + wxString(wxT(" / ") ) +wxU(psz_total) ;
145         }
146     }
147 #endif
148
149 #undef WIN32
150 }