Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

python - Display and play audio files

I am new to python, and I'm trying to build a simple recording program. With the some help from my previous question, I was able to add a timestamp for each recorded file

EDIT:

I did some research and decided on displaying the files with filechooser... this still does not work

def openfiles(self, *args):

    satter2 = BoxLayout(pos= (629, 950), size_hint= (.1,.1))
    self.fclv = FileChooserListView(path= '/sdcard/', filters= [‘*.3gp’])
    self.fclv.bind(on_selection= self.pressed(fclv.selection)
    scatter.add_widget(self.fclv)

    self.add_widget(satter2)


def pressed(self, filename):
     #with open(os.path.join(path, filename[0])) 


    if self.soundf is None:
        self.soundf = SoundLoader.load(self.path)
    if self.soundf.status != 'stop':
        self.soundf.stop()
    self.soundf.loop = False
    self.soundf.play()
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is a simple example of how to show all 3gp files in your current directory.

from kivy.app import App
from kivy.uix.filechooser import FileChooserListView
from kivy.uix.boxlayout import BoxLayout


class MyLayout(BoxLayout):

    def __init__(self,**kwargs):
        super(MyLayout,self).__init__(**kwargs)
        self.fclv = FileChooserListView(path= '.', filters= ['*.3gp'])
        self.add_widget(self.fclv)


class MyApp(App):

    def build(self):
        return MyLayout()


MyApp().run()

Result is:

Files in a ListView


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...