1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include "dialogs/vlm/vlm_streampanel.hpp"
26 #include "dialogs/vlm/vlm_stream.hpp"
27 #include "dialogs/vlm/vlm_slider_manager.hpp"
29 #include "dialogs/vlm/vlm_panel.hpp"
31 #include "bitmaps/play.xpm"
32 #include "bitmaps/pause.xpm"
33 #include "bitmaps/stop.xpm"
34 #include "bitmaps/trash.xpm"
35 #include "bitmaps/edit.xpm"
46 BEGIN_EVENT_TABLE( VLMBroadcastStreamPanel, wxPanel )
47 EVT_BUTTON( BPlay_Event, VLMBroadcastStreamPanel::OnPlay )
48 EVT_BUTTON( BStop_Event, VLMBroadcastStreamPanel::OnStop )
49 EVT_BUTTON( BEdit_Event, VLMBroadcastStreamPanel::OnEdit )
50 EVT_BUTTON( BTrash_Event, VLMBroadcastStreamPanel::OnTrash )
51 EVT_COMMAND_SCROLL( BSlider_Event, VLMBroadcastStreamPanel::OnSliderUpdate )
54 /***********************************************************************
56 ***********************************************************************/
57 VLMStreamPanel::VLMStreamPanel( intf_thread_t * _p_intf, wxWindow * _p_parent ):
58 wxPanel( _p_parent, -1, wxDefaultPosition, wxDefaultSize )
64 VLMStreamPanel::~VLMStreamPanel()
68 /***********************************************************************
70 ***********************************************************************/
71 VLMBroadcastStreamPanel::VLMBroadcastStreamPanel( intf_thread_t* _p_intf,
72 wxWindow *_p_parent , VLMBroadcastStream *_stream ):
73 VLMStreamPanel( _p_intf, _p_parent ),
76 wxStaticBox *box = new wxStaticBox( this, -1,
77 wxU( p_stream->p_media->psz_name ) );
79 wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( box, wxHORIZONTAL );
81 play_button = new wxBitmapButton( this, BPlay_Event,
82 wxBitmap( play_xpm ) );
83 play_button->SetToolTip( wxU(_("Play/Pause") ) );
84 box_sizer->Add( play_button, 0, wxEXPAND | wxALL, 5 );
86 wxBitmapButton *stop_button = new wxBitmapButton( this, BStop_Event,
87 wxBitmap( stop_xpm ) );
88 stop_button->SetToolTip( wxU(_("Stop") ) );
89 box_sizer->Add( stop_button, 0, wxEXPAND | wxALL, 5 );
91 p_slider = new wxSlider( this, BSlider_Event, 0, 0,
92 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
94 box_sizer->Add( p_slider, 1, wxEXPAND | wxALL, 5 );
96 p_time = new wxStaticText( this, -1, wxU( "0:00:00 / 0:00:00") );
97 box_sizer->Add( p_time, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
99 wxBitmapButton *edit_button = new wxBitmapButton( this, BEdit_Event,
100 wxBitmap( edit_xpm ) );
101 edit_button->SetToolTip( wxU( _("Edit") ) );
102 box_sizer->Add( edit_button, 0, wxEXPAND | wxALL , 5 );
104 wxBitmapButton *trash_button = new wxBitmapButton( this, BTrash_Event,
105 wxBitmap( trash_xpm ) );
106 trash_button->SetToolTip( wxU( _("Delete" ) ) );
107 box_sizer->Add( trash_button, 0, wxEXPAND | wxALL , 5 );
110 SetSizerAndFit( box_sizer );
112 p_sm = new VLMSliderManager( p_intf, this );
115 VLMBroadcastStreamPanel::~VLMBroadcastStreamPanel()
119 void VLMBroadcastStreamPanel::TogglePlayButton( int state )
121 if( state == PLAYING_S )
123 play_button->SetBitmapLabel( wxBitmap( pause_xpm ) );
125 if( state == PAUSE_S )
127 play_button->SetBitmapLabel( wxBitmap( play_xpm ) );
131 void VLMBroadcastStreamPanel::Update()
133 /* Update managed slider */
135 p_time->SetLabel( p_sm->time_string );
138 void VLMBroadcastStreamPanel::OnPlay( wxCommandEvent &event )
140 /* FIXME: Factorize input / VLM code here */
141 /* Handle multiple instance */
142 if( p_stream->p_media->i_instance > 0 &&
143 p_stream->p_media->instance[0]->p_input )
146 vlc_object_hold( p_stream->p_media->instance[0]->p_input );
147 var_Get( p_stream->p_media->instance[0]->p_input, "state", &val );
148 if( val.i_int != PAUSE_S )
156 val.i_int = PLAYING_S;
158 var_Set( p_stream->p_media->instance[0]->p_input, "state", val );
159 TogglePlayButton( val.i_int );
160 vlc_object_release( p_stream->p_media->instance[0]->p_input );
165 TogglePlayButton( PLAYING_S );
169 void VLMBroadcastStreamPanel::OnStop( wxCommandEvent &event )
174 void VLMBroadcastStreamPanel::OnEdit( wxCommandEvent &event )
176 VLMEditStreamFrame *p_frame =
177 new VLMEditStreamFrame( p_intf, this, p_stream->p_vlm, true,
182 void VLMBroadcastStreamPanel::OnTrash( wxCommandEvent &event )
187 void VLMBroadcastStreamPanel::OnSliderUpdate( wxScrollEvent& event )
189 p_sm->ProcessUpdate( event );
192 /***********************************************************************
194 ***********************************************************************/
195 VLMVODStreamPanel::VLMVODStreamPanel( intf_thread_t* _p_intf,
196 wxWindow *_p_parent , VLMVODStream *_stream ):
197 VLMStreamPanel( _p_intf, _p_parent ),
202 VLMVODStreamPanel::~VLMVODStreamPanel()