~ubuntu-branches/debian/jessie/banshee-community-extensions/jessie

« back to all changes in this revision

Viewing changes to src/Karaoke/Banshee.Karaoke/KaraokeService.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-09-20 18:45:46 UTC
  • mfrom: (1.2.9 upstream) (5.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20110920184546-3ahue2qplydc4t0e
Tags: 2.2.0-1
* [4940fab] Imported Upstream version 2.2.0
  + Notable bug fixes:
    - Karaoke: Fix crash when switching to Now Playing
    - Lyrics: Fix crash when switching to Now Playing

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
namespace Banshee.Karaoke
39
39
{
40
 
 
41
40
    public class KaraokeService : IExtensionService, IDelayedInitializeService, IDisposable
42
41
    {
43
 
 
44
42
        Bin audiobin;
45
43
        Bin playbin;
46
44
        Bin audiotee;
70
68
            effect_level = effect_level / 100;
71
69
            filter_band = (float)FilterBandEntry.Get ();
72
70
            filter_width = (float)FilterWidthEntry.Get ();
73
 
 
74
71
        }
75
72
 
76
73
        #region IExtensionService implementation
109
106
            action_service.UIManager.InsertActionGroup (actions, 0);
110
107
            ui_menu_id = action_service.UIManager.AddUiFromResource ("KaraokeMenu.xml");
111
108
            ui_button_id = action_service.UIManager.AddUiFromResource ("KaraokeButton.xml");
112
 
 
113
109
        }
114
110
 
115
111
        /// <summary>
133
129
                audiokaraoke.SetFloatProperty ("level", effect_level);
134
130
                audiokaraoke.SetFloatProperty ("mono-level", effect_level);
135
131
            }
136
 
 
137
132
        }
138
133
 
139
134
        /// <summary>
153
148
        void OnLyricsEnabledChanged ()
154
149
        {
155
150
            EventHandler handler = LyricsEnabledChanged;
156
 
            if (handler != null)
 
151
            if (handler != null) {
157
152
                handler (this, new EventArgs ());
 
153
            }
158
154
        }
159
155
 
160
156
        void IDelayedInitializeService.DelayedInitialize ()
165
161
            audiobin = new Bin (ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements ()[1]);
166
162
            audiotee = new Bin (ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements ()[2]);
167
163
 
168
 
            if (playbin.IsNull ())
 
164
            if (playbin.IsNull ()) {
169
165
                Hyena.Log.Debug ("[Karaoke] Playbin is not yet initialized, cannot start Karaoke Mode");
 
166
            }
170
167
 
171
168
            audiokaraoke = audiobin.GetByName ("karaoke");
172
169
 
173
 
            if (audiokaraoke.IsNull ())
174
 
            {
 
170
            if (audiokaraoke.IsNull ()) {
175
171
                audiokaraoke = ElementFactory.Make ("audiokaraoke","karaoke");
176
172
 
177
173
                //add audiokaraoke to audiobin
193
189
                audiokaraoke.SetFloatProperty ("level", effect_level);
194
190
                audiokaraoke.SetFloatProperty ("mono-level", effect_level);
195
191
            }
196
 
 
197
 
            //Hyena.Log.DebugFormat ("Karaoke service has been initialized! {0}", audiobin.ToString ());
198
192
        }
199
193
        #endregion
200
194
 
201
195
        #region IDisposable implementation
202
196
        void IDisposable.Dispose ()
203
197
        {
204
 
            if (has_karaoke && !playbin.IsNull () && !audiokaraoke.IsNull ())
205
 
            {
 
198
            if (has_karaoke && !playbin.IsNull () && !audiokaraoke.IsNull ()) {
206
199
                audiokaraoke.SetFloatProperty ("level", 0);
207
200
                audiokaraoke.SetFloatProperty ("mono-level", 0);
208
201
            }
209
202
 
210
 
            if (ui_menu_id > 0)
 
203
            if (ui_menu_id > 0) {
211
204
                action_service.UIManager.RemoveUi (ui_menu_id);
212
 
 
213
 
            if (ui_button_id > 0)
 
205
            }
 
206
            if (ui_button_id > 0) {
214
207
                action_service.UIManager.RemoveUi (ui_button_id);
215
 
 
216
 
            if (actions != null)
 
208
            }
 
209
            if (actions != null) {
217
210
                action_service.UIManager.RemoveActionGroup (actions);
218
 
            actions = null;
 
211
                actions = null;
 
212
            }
219
213
        }
220
214
        #endregion
221
215
 
241
235
 
242
236
        public void ApplyKaraokeEffectLevel (float new_level)
243
237
        {
244
 
            if (!karaoke_enabled) return;
 
238
            if (!karaoke_enabled) {
 
239
                return;
 
240
            }
245
241
            audiokaraoke.SetFloatProperty ("level", new_level);
246
242
            audiokaraoke.SetFloatProperty ("mono-level", new_level);
247
243
        }