Today I was preparing some slides for my upcoming talks at 7th Encuentro Linux 2006 in Chile. I had planned to use some music in sync with some slides. However embbeding music in OpenOffice Impress is not easy. Also I’d prefer to use a PDF with evince in presentation mode. Solution? Using evince for display slides and totem for playing the music, both syncronized using a dogtail script. Here are the fundamentals:
Guess what page evince is displaying from:
If the page has changed, check in an array if the new slide has music. If no music associated, press pause button on totem. If music associated, search totem playlist for the song and press play button. That’s all: 30 lines of python where you can embbed your music array:
#!/usr/bin/python import gtk from dogtail.tree import root music = {} music['3'] = '03. Nina Simone - Pirate Jenny' music['5'] = '04-raimon - diguem no.mp3' current = '0' def check_music(): global music, page, play, totem, current if current == page.text: return True else: current = page.text if music.has_key(page.text): entry = totem.child(roleName='table cell', name=music[page.text]) entry.doAction('activate') if play.name == 'gtk-media-play': play.click() else: if play.name == 'gtk-media-pause': play.click() return True evince = root.application('evince') toolbar = evince.child(roleName='tool bar') page = toolbar.child(roleName='text') totem = root.application('totem') play = totem.child(name='gtk-media-play') tag = gtk.timeout_add (500, check_music) gtk.main()
Next improvement would be adding a gui for creating playlists, associating PDF presentation and slides, lauching evince and launching totem with the created playlist