PyZombis aayush/issue#218@321ced6
Social
Runestone in social media:
Follow @iRunestone
Our Facebook Page
Help support us:
Search
Table of Contents
Book Index
User
Assignments
Practice
Change Course
Instructor's Page
Progress Page
Edit Profile
Change Password
Register
Login
Dark Mode
Scratch Activecode
Help
FAQ
Instructors Guide
About Runestone
Report A Problem
2.
Pero la canción no termina…
¶
from browser import document, html sonido = 'https://bigsoundbank.com/UPLOAD/mp3/0751.mp3' def iniciar(): pista.play() print("Audio iniciado") def detener(): pista.pause() pista.currentTime = 0 print("Audio detenido") def terminar(ev): pista.pause() if app_div in document: app_div.remove() print("Aplicación terminada") elemento_audio = html.AUDIO(src=sonido) boton_iniciar = html.BUTTON('Iniciar') boton_iniciar.bind('click', lambda ev: iniciar()) boton_detener = html.BUTTON('Detener') boton_detener.bind('click', lambda ev: detener()) app_div = html.DIV() app_div <= elemento_audio app_div <= boton_iniciar app_div <= boton_detener document <= app_div document.bind('beforeunload', terminar) pista = elemento_audio
2.1.
Un solo botón
¶
from browser import document, html sonido = 'https://bigsoundbank.com/UPLOAD/mp3/0751.mp3' def terminar(): pista.pause() if app_div in document: app_div.remove() def cambiar(ev): if ev.target.checked: pista.play() else: pista.pause() elemento_audio = html.AUDIO(src=sonido) boton_reproduccion = html.INPUT(type='checkbox') etiqueta_reproduccion = html.LABEL('Reproducir sonido', style={'margin-left': '10px'}) etiqueta_reproduccion <= boton_reproduccion app_div = html.DIV() app_div <= elemento_audio app_div <= etiqueta_reproduccion document <= app_div boton_reproduccion.bind('change', cambiar) document.bind('beforeunload', terminar) pista = elemento_audio
You have attempted
of
activities on this page