[gcompris/gcomprismusic] Added speed feature for the player and corrected the play pause button



commit 81c02a98667484bdc868e9735857b9f340000811
Author: Karthik Subramanian <itskarthik s gmail com>
Date:   Sun Aug 14 23:56:54 2011 +0530

    Added speed feature for the player and corrected the play pause button

 .../resources/singalong/backward.svg               |  102 ++++++++++++++++++++
 .../resources/singalong/forward.svg                |  102 ++++++++++++++++++++
 src/singalong-activity/singalong.py                |   58 ++++++++++-
 3 files changed, 256 insertions(+), 6 deletions(-)
---
diff --git a/src/singalong-activity/resources/singalong/backward.svg b/src/singalong-activity/resources/singalong/backward.svg
new file mode 100644
index 0000000..81f02ca
--- /dev/null
+++ b/src/singalong-activity/resources/singalong/backward.svg
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   version="1.1"
+   width="160.71429"
+   height="160.71429"
+   id="svg3390">
+  <defs
+     id="defs3392">
+    <linearGradient
+       x1="301.71274"
+       y1="118.00021"
+       x2="345.2388"
+       y2="41.87933"
+       id="linearGradient3720-1"
+       xlink:href="#linearGradient3714-1"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       id="linearGradient3714-1">
+      <stop
+         id="stop3716-3"
+         style="stop-color:#f9f9f9;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3722-8"
+         style="stop-color:#f90700;stop-opacity:0.9464286"
+         offset="1" />
+      <stop
+         id="stop3718-7"
+         style="stop-color:#f9f9f9;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <filter
+       x="-0.078430913"
+       y="-0.10581781"
+       width="1.1568618"
+       height="1.2116356"
+       color-interpolation-filters="sRGB"
+       id="filter3710-4">
+      <feGaussianBlur
+         id="feGaussianBlur3712-2"
+         stdDeviation="1.6320684" />
+    </filter>
+    <linearGradient
+       x1="44.285713"
+       y1="202.5587"
+       x2="44.285713"
+       y2="53.571426"
+       id="linearGradient2850-77"
+       xlink:href="#linearGradient2844-9"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       id="linearGradient2844-9">
+      <stop
+         id="stop2846-3"
+         style="stop-color:#fafafa;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop2848-1"
+         style="stop-color:#ffffff;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+  </defs>
+  <g
+     transform="translate(-368.21428,-452.00503)"
+     id="layer1">
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="matrix(-1.035002,0,0,1.0615888,494.97866,476.63421)"
+       id="path2816-1-4-98"
+       style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="matrix(-0.97520185,0,0,1.0002526,492.33037,479.62922)"
+       id="path2816-65"
+       style="fill:#ff5555;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="matrix(-0.97520185,0,0,1.0002526,492.33532,479.15468)"
+       id="path2816-1-0"
+       style="fill:url(#linearGradient2850-77);fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 342.85715,84.285713 a 27.142857,15 0 1 1 -54.28571,0 27.142857,15 0 1 1 54.28571,0 z"
+       transform="matrix(-0.6450823,0.36005563,0.36120618,0.64302752,594.26323,313.80794)"
+       id="path2852-2"
+       style="opacity:0.5;fill:url(#linearGradient3720-1);fill-opacity:1;fill-rule:evenodd;stroke:none;filter:url(#filter3710-4)" />
+    <path
+       d="m 116.27094,45 -99.406408,57.39231 0,-114.784623 L 116.27094,45 z"
+       transform="matrix(-0.83321701,0,0,0.85462048,477.05348,493.48611)"
+       id="path2820-4-9"
+       style="fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:#d7d7d7;stroke-width:3.51121688;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+    <path
+       d="m 116.27094,45 -99.406408,57.39231 0,-114.784623 L 116.27094,45 z"
+       transform="matrix(-0.83321701,0,0,0.85462048,514.38979,493.48611)"
+       id="path2820-4"
+       style="fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:#d7d7d7;stroke-width:3.51121688;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+  </g>
+</svg>
diff --git a/src/singalong-activity/resources/singalong/forward.svg b/src/singalong-activity/resources/singalong/forward.svg
new file mode 100644
index 0000000..d11d72a
--- /dev/null
+++ b/src/singalong-activity/resources/singalong/forward.svg
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   version="1.1"
+   width="160.71429"
+   height="160.71429"
+   id="svg3390">
+  <defs
+     id="defs3392">
+    <linearGradient
+       x1="301.71274"
+       y1="118.00021"
+       x2="345.2388"
+       y2="41.87933"
+       id="linearGradient3720-1"
+       xlink:href="#linearGradient3714-1"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       id="linearGradient3714-1">
+      <stop
+         id="stop3716-3"
+         style="stop-color:#f9f9f9;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3722-8"
+         style="stop-color:#f90700;stop-opacity:0.9464286"
+         offset="1" />
+      <stop
+         id="stop3718-7"
+         style="stop-color:#f9f9f9;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <filter
+       x="-0.078430913"
+       y="-0.10581781"
+       width="1.1568618"
+       height="1.2116356"
+       color-interpolation-filters="sRGB"
+       id="filter3710-4">
+      <feGaussianBlur
+         id="feGaussianBlur3712-2"
+         stdDeviation="1.6320684" />
+    </filter>
+    <linearGradient
+       x1="44.285713"
+       y1="202.5587"
+       x2="44.285713"
+       y2="53.571426"
+       id="linearGradient2850-77"
+       xlink:href="#linearGradient2844-9"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       id="linearGradient2844-9">
+      <stop
+         id="stop2846-3"
+         style="stop-color:#fafafa;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop2848-1"
+         style="stop-color:#ffffff;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+  </defs>
+  <g
+     transform="translate(-368.21428,-452.00503)"
+     id="layer1">
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="matrix(1.0613208,0,0,1.0613208,401.57008,475.50571)"
+       id="path2816-1-4-98"
+       style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="translate(404.28572,478.49996)"
+       id="path2816-65"
+       style="fill:#ff5555;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 120,53.571426 a 75.714287,75.714287 0 1 1 -151.428574,0 75.714287,75.714287 0 1 1 151.428574,0 z"
+       transform="translate(404.28064,478.02554)"
+       id="path2816-1-0"
+       style="fill:url(#linearGradient2850-77);fill-opacity:1;fill-rule:evenodd;stroke:none" />
+    <path
+       d="m 342.85715,84.285713 a 27.142857,15 0 1 1 -54.28571,0 27.142857,15 0 1 1 54.28571,0 z"
+       transform="matrix(0.66148592,0.35996471,-0.3703912,0.64286514,299.76084,312.72056)"
+       id="path2852-2"
+       style="opacity:0.5;fill:url(#linearGradient3720-1);fill-opacity:1;fill-rule:evenodd;stroke:none;filter:url(#filter3710-4)" />
+    <path
+       d="m 116.27094,45 -99.406408,57.39231 0,-114.784623 L 116.27094,45 z"
+       transform="matrix(0.85440466,0,0,0.85440466,419.95107,492.35336)"
+       id="path2820-4-9"
+       style="fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:#d7d7d7;stroke-width:3.51121688;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+    <path
+       d="m 116.27094,45 -99.406408,57.39231 0,-114.784623 L 116.27094,45 z"
+       transform="matrix(0.85440466,0,0,0.85440466,381.66536,492.35336)"
+       id="path2820-4"
+       style="fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:#d7d7d7;stroke-width:3.51121688;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+  </g>
+</svg>
diff --git a/src/singalong-activity/singalong.py b/src/singalong-activity/singalong.py
index 8ef3e12..2230f24 100644
--- a/src/singalong-activity/singalong.py
+++ b/src/singalong-activity/singalong.py
@@ -73,15 +73,16 @@ class Gcompris_singalong:
     # Create our rootitem. We put each canvas item in it so at the end we
     # only have to kill it. The canvas deletes all the items it contains
     # automaticaly.
-    self.rootitem = goocanvas.Group(parent =                self.gcomprisBoard.canvas.get_root_item())
+    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())
 
     self.mapping = { 'C' : 310, 'D' : 340 , 'E' : 370, 'F' : 400, 'G' : 430, 'A' : 460, 'C3': 490 }
-    self.currentsong = "twinkle"
+    
 
     self.mute = False
     self.notecount = 0
     self.count = 0
     self.delay = 30
+    self.play = 1
 
     goocanvas.Text(
       parent = self.rootitem,
@@ -104,8 +105,9 @@ class Gcompris_singalong:
         )
     self.mute_button = goocanvas.Image(
         parent = self.rootitem,
-        x = 600,
-        y = 320,
+        tooltip = _('Mute'),
+        x = 540,
+        y = 370,
         width = 50,
         height = 50,
         pixbuf = gcompris.utils.load_pixmap("singalong/audio-volume-muted.png")
@@ -116,12 +118,39 @@ class Gcompris_singalong:
 
     self.play_button = goocanvas.Image(
         parent = self.rootitem,
+        tooltip = _('Play'),
         x = 600,
-        y = 400,
+        y = 370,
         width = 50,
         height = 50,
         pixbuf = gcompris.utils.load_pixmap("singalong/play_button.png")
         )
+     
+    self.faster_button = goocanvas.Image(
+        parent = self.rootitem,
+        tooltip = _('Faster'),
+        x = 240,
+        y = 370,
+        width = 50,
+        height = 50,
+        pixbuf = gcompris.utils.load_pixmap("singalong/forward.svg")
+        )
+    gcompris.utils.item_focus_init(self.faster_button, None)
+    self.faster_button.connect("button-press-event", self.play_faster)
+
+
+    self.slower_button = goocanvas.Image(
+        parent = self.rootitem,
+        tooltip = _('Slower'),
+        x = 180,
+        y = 370,
+        width = 50,
+        height = 50,
+        pixbuf = gcompris.utils.load_pixmap("singalong/backward.svg")
+        )
+
+    gcompris.utils.item_focus_init(self.slower_button, None)
+    self.slower_button.connect("button-press-event", self.play_slower)
 
     gcompris.utils.item_focus_init(self.play_button, None)
     self.play_button.connect("button-press-event", self.play_again)
@@ -171,8 +200,24 @@ class Gcompris_singalong:
     self.play_song()
   
   def play_again(self, item, event, attr):
+    if self.play == 1:
+      length = len(self.songs[self.gcomprisBoard.level-1].notes)
+      self.count = length - 1 
+      self.play = 0
+    else : 
+      self.count = 0
+      self.play = 1
+      self.play_song()
+      
+
+  def play_faster(self, item, event, attr):
     self.count = 0
-    self.status_timer = self.delay
+    self.delay = self.delay - 5
+    self.play_song()
+    
+  def play_slower(self, item, event, attr):
+    self.count = 0
+    self.delay = self.delay + 5
     self.play_song()
 
   def mute_and_play(self, item, event, attr):
@@ -203,6 +248,7 @@ class Gcompris_singalong:
     return config
 
   def play_song(self):
+   self.status_timer = self.delay
    
    self.timer_inc  = gobject.timeout_add(self.status_timer, self.timer_loop)    
         



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]