Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...