Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Narration problem of E-book — Gideros Forum

Narration problem of E-book

edited January 2013 in Bugs and issues
Hi everyone,

I am a student at Bilkent University CTE department. We use gideros e-book template and we try to create new e-book for our final projects of CTE322 Multimedia Design and Development course. I have a problem which is that I used narration for each page but if I click next or previous page button when the current page narration does not finish, the sound overlap. How I can stop the current page narration when user click next or previous button without finishing current page narration.

Thank You,

Selçuk Çağan

Comments

  • OZAppsOZApps Guru
    Accepted Answer
    did you try to stop the sound playing before you change the page?

    you get the channel when you play the sound, then use the stop on that channel.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • yes ı tried but this time there is no sound the current page
    each page similir code
    for example
    page1 sound code is:
    music = Sound.new("sounds/0-9.mp3")
    local channel = music:play(0,0)
    channel:setVolume(0.6)

    if I write channel:stop(), there is no sound the current page. Do you mean something like that? It does not work :(

    page2 sound code is
    music = Sound.new("sounds/10-19.mp3")
    local channel = music:play(0,0)
    channel:setVolume(0.6)

    My problem is when I click next button before ending page2 sounds and page1 sounds overlap.
  • Also I write page2 channel:stop("sounds/0-9.mp3") but it does not work again :/
  • OZAppsOZApps Guru
    edited January 2013
    @cteselcukagan,
    could it be a bug in the version of Gideros you are using? If not, try this code it works absolutely fine. I have run/tested this on 2012.09
    local music = Sound.new("sounds/0-9.mp3")
    local channel = music:play()
    channel:setVolume(0.6)
     
    Timer.delayedCall(3000, function() channel:stop() end)
    the point being that the channel can stop the sound from being played, hope you are retaining the channel and not overwriting it with another.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • I also use same version gideros studio.
    Thank you it works but it is temporarily solution for me because there is 18 more pages and each page has its own narration. When I move to second to third page sound again overlap.

    Do you have any more suggestion? :/
  • Also when I move second page to first page, again sound overlap :(
  • can you post the code for any one page, not highlights but the code that you have in the page (to help you resolve this) (assuming that the sound code is nearly the same for all pages)

    because if you have the code right, it should simply work. So curious to know why it is not working for you.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • This is page2.lua
    Page2 = gideros.class(Sprite)

    function Page2:init( pageNo, parent)
    self.no = pageNo

    self.background = Bitmap.new(TextureRegion.new(Texture.new("imgs/background.png", true)))

    self:addChild(self.background)
    self:addChild(AnimatedSprite.new())

    local heading = TTFont.new("verdana.ttf","20")
    local head1 = TextField.new(heading,"Numbers in English (10-19)")
    head1:setPosition(10,25)
    head1:setTextColor(0xB8860B)
    self:addChild(head1)

    local headTTF1 = TTFont.new("arial.ttf","16")

    local text1 = TextField.new(headTTF1, "10 - ten")
    text1:setPosition(50, 60)
    text1:setTextColor(0xB8860B)
    self:addChild(text1)

    local text2 = TextField.new(headTTF1, "11 - eleven")
    text2:setPosition(50, 95)
    text2:setTextColor(0xB8860B)
    self:addChild(text2)

    local text3 = TextField.new(headTTF1, "12 - twelve")
    text3:setPosition(50,130)
    text3:setTextColor(0xB8860B)
    self:addChild(text3)

    local text4 = TextField.new(headTTF1, "13 - thirteen")
    text4:setPosition(50, 165)
    text4:setTextColor(0xB8860B)
    self:addChild(text4)

    local text5 = TextField.new(headTTF1, "14 - fourteen")
    text5:setPosition(50, 200)
    text5:setTextColor(0xB8860B)
    self:addChild(text5)

    local text6 = TextField.new(headTTF1, "15 - fifteen")
    text6:setPosition(50, 235)
    text6:setTextColor(0xB8860B)
    self:addChild(text6)

    local text7 = TextField.new(headTTF1, "16 - sixteen")
    text7:setPosition(50, 270)
    text7:setTextColor(0xB8860B)
    self:addChild(text7)

    local text8 = TextField.new(headTTF1, "17 - seventeen")
    text8:setPosition(50, 305)
    text8:setTextColor(0xB8860B)
    self:addChild(text8)

    local text9 = TextField.new(headTTF1, "18 - eighteen")
    text9:setPosition(50, 340)
    text9:setTextColor(0xB8860B)
    self:addChild(text9)

    local text10 = TextField.new(headTTF1, "19 - nineteen")
    text10:setPosition(50, 375)
    text10:setTextColor(0xB8860B)
    self:addChild(text10)

    music = Sound.new("sounds/10-19.mp3")
    local channel = music:play(0,0)
    channel:setVolume(0.6)

    end

    This is page1.lua

    Page1 = gideros.class(Sprite)

    function Page1:init( pageNo, parent)
    self.no = pageNo

    self.background = Bitmap.new(TextureRegion.new(Texture.new("imgs/background.png", true)))

    self:addChild(self.background)


    self:addChild(AnimatedSprite.new())


    local heading = TTFont.new("verdana.ttf","20")
    local head1 = TextField.new(heading,"Numbers in English (0-9)")
    head1:setPosition(10,25)
    head1:setTextColor(0xB8860B)
    self:addChild(head1)


    local headTTF1 = TTFont.new("arial.ttf","16")

    local text1 = TextField.new(headTTF1, "0 - zero")
    text1:setPosition(50, 60)
    text1:setTextColor(0xB8860B)
    self:addChild(text1)

    local text2 = TextField.new(headTTF1, "1 - one")
    text2:setPosition(50, 95)
    text2:setTextColor(0xB8860B)
    self:addChild(text2)

    local text3 = TextField.new(headTTF1, "2 - two")
    text3:setPosition(50, 130)
    text3:setTextColor(0xB8860B)
    self:addChild(text3)

    local text4 = TextField.new(headTTF1, "3 - three")
    text4:setPosition(50, 165)
    text4:setTextColor(0xB8860B)
    self:addChild(text4)

    local text5 = TextField.new(headTTF1, "4 - four")
    text5:setPosition(50, 200)
    text5:setTextColor(0xB8860B)
    self:addChild(text5)

    local text6 = TextField.new(headTTF1, "5 - five")
    text6:setPosition(50, 235)
    text6:setTextColor(0xB8860B)
    self:addChild(text6)

    local text7 = TextField.new(headTTF1, "6 - six")
    text7:setPosition(50, 270)
    text7:setTextColor(0xB8860B)
    self:addChild(text7)

    local text8 = TextField.new(headTTF1, "7 - seven")
    text8:setPosition(50, 305)
    text8:setTextColor(0xB8860B)
    self:addChild(text8)

    local text9 = TextField.new(headTTF1, "8 - eight")
    text9:setPosition(50, 340)
    text9:setTextColor(0xB8860B)
    self:addChild(text9)

    local text10 = TextField.new(headTTF1, "9 - nine")
    text10:setPosition(50, 375)
    text10:setTextColor(0xB8860B)
    self:addChild(text10)

    music = Sound.new("sounds/0-9.mp3")
    local channel = music:play(0,0)
    channel:setVolume(0.6)

    end

    This is sceneContoller.lua
    sceneController = gideros.class(Sprite)

    local pages = {}
    -- create a list of pages, to set their order of apperance.
    pages[1] = "Page0"
    pages[2] = "Page1"
    pages[3] = "Page2"
    pages[4] = "Page3"
    pages[5] = "Page4"
    pages[6] = "Page5"
    pages[7] = "Page6"
    pages[8] = "Page7"
    pages[9] = "Page8"
    pages[10] = "Page9"
    pages[11] = "Page10"
    pages[12] = "Page11"
    pages[13] ="Page12"
    pages[14] ="Page13"
    pages[15] ="Page14"
    pages[16] ="Page15"
    pages[17] ="Page16"
    pages[18] ="Page17"
    pages[19] ="Page18"
    pages[20] ="Page19"
    pages[21] ="Page20"
    pages[22] ="Page21"
    pages[23] ="Page22"

    local beginx = 225
    local beginy = 450
    local leftx= 260
    local lefty= 450
    local rightx = 295
    local homex = 190
    local homey = 450
    local righty = 450


    function sceneController:init()
    self.scenes = SceneManager.new({ --scenes are defined
    ["Page0"] = Page0,
    ["Page1"] = Page1,
    ["Page2"] = Page2,
    ["Page3"] = Page3,
    ["Page4"] = Page4,
    ["Page5"] = Page5,
    ["Page6"] = Page6,
    ["Page7"] = Page7,
    ["Page8"] = Page8,
    ["Page9"] = Page9,
    ["Page10"] = Page10,
    ["Page11"] = Page11,
    ["Page12"] = Page12,
    ["Page13"] = Page13,
    ["Page14"] = Page14,
    ["Page15"] = Page15,
    ["Page16"] = Page16,
    ["Page17"] = Page17,
    ["Page18"] = Page18,
    ["Page19"] = Page19,
    ["Page20"] = Page20,
    ["Page21"] = Page21,
    ["Page22"] = Page22,
    })

    music = Sound.new("sounds/music4.mp3")

    local channel = music:play(0, 1000)
    channel:setVolume(0.2)
    self:addChild(self.scenes)
    -- add the first page
    self.scenes:changeScene("Page0")
    self.pageNo = 1

    -- this is the button on the left. to go back
    self.left = Button.new(Bitmap.new(Texture.new("imgs/left-up.png")), Bitmap.new(Texture.new("imgs/left-down.png")))
    self.left:setPosition(leftx, lefty)
    self:addChild(self.left)

    self.home = Button.new(Bitmap.new(Texture.new("imgs/credits-up.png")), Bitmap.new(Texture.new("imgs/credits_down.png")))
    self.home:setPosition(homex, homey)
    self:addChild(self.home)


    -- thins is the button on the right, to go fprward.
    self.right = Button.new(Bitmap.new(Texture.new("imgs/right-up.png")), Bitmap.new(Texture.new("imgs/right-down.png")))
    self.right:setPosition(rightx, righty)
    self:addChild(self.right)

    -- "click" event is mapped to the function of scenecontroller, self.leftClick
    -- when the "click" event is pressed, this function will be called.
    self.left:addEventListener("click", self.leftClick, self)
    self.right:addEventListener("click", self.rightClick, self)
    self.home:addEventListener("click",self.homeClick,self)
    end

    function sceneController:homeClick()
    print(self.pageNo)
    self.pageNo = 23
    self.scenes:changeScene(pages[self.pageNo],1, SceneManager.flipWithShade, easing.inBack)
    end


    function sceneController:leftClick()
    print(self.pageNo)
    -- previous index
    self.pageNo = self.pageNo - 1
    if self.pageNo < 1 then self.pageNo = 1 end
    print(self.pageNo)
    -- give next scene, the duration, the effect, and the easing mode. you can play with them to see how they look.
    self.scenes:changeScene(pages[self.pageNo],1, SceneManager.flipWithShade, easing.inBack)

    end

    function sceneController:rightClick()
    self.pageNo = self.pageNo + 1
    if self.pageNo > 23 then self.pageNo = 1 end

    self.scenes:changeScene(pages[self.pageNo],1, SceneManager.flipWithFade, easing.inBack)
    end

    This is main.lua
    local sc = sceneController.new()
    stage:addChild(sc)
  • @cteselcukcagan: try add this code in each page init
    self.music = Sound.new("sounds/0-9.mp3")		
    	self.channel  = self.music:play(0, 1000)
    	self.channel:setVolume(0.6)
     
    	self:addEventListener("exitBegin", function() self.channel:stop() end)
  • @cteselcukcagan: music var is global, so when you change scene, it's assigned to other object.
  • @cteselcukcagan, as @hnim mentioned and since you are using the Scene Manager, you need to set up an event listener for events as appropriate. In this case you might need to use the exitBegin. Where you can stop the music from playing on exitBegin.

    Another thing that you can do is to save the channel to the self object and remove it if the channel object is not nil
    if self.channel then 
      self.channel:stop()
      self.channel = nil
    end
    In case you need to refer to understand a bit more about the SceneManager, there is a lovely article on Gideros Tutorials at http://www.giderosmobile.com/blog/2011/11/17/gideros-scene-manager/
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • edited January 2013
    thank you so much your valuable responses :)
    I promise after finishing my final exam I look at this book now I am following you twitter OZApps :)
  • It is completely work thank you so much I am so happy :) :)

    Likes: gorkem

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.