python定时播放音乐程序_python实现定时播放mp3

python实现定时播放mp3

程序很简单,主要是 mp3play 模块的应用

import mp3play, time

filename = “Should It Matter.mp3”

clip = mp3play.load(filename)

while 1:

if time.localtime().tm_min % 30 == 0:

clip.play()

print “\nStart to play”

time.sleep(clip.seconds())

clip.stop()

print “Stop”

print ‘>’,

time.sleep(30) #暂停30秒(不是30分钟)

演示图:

以上所述就是本文的全部内容了,希望大家能够喜欢。

时间: 2015-03-26

本文实例讲述了python使用win32com库播放mp3文件的方法.分享给大家供大家参考.具体实现方法如下: # Python supports COM, if you have the Win32 extensions # check your Python folder eg. D:\Python23\Lib\site-packages\win32com # also http://starship.python.net/crew/mhammond/win32/Downloads.html

本文实例讲述了Python修改MP3文件的方法.分享给大家供大家参考.具体如下: 用这个程序修改后的MP3比原来要小一些了,因为一张图片被删除了,起到了给MP3″瘦身”的作用.在一些mp3中,每个都有一张400多K的图片,10几个MP3,就相当一个普通MP3文件的大小了. # –– coding: cp936 –– “”” 将MP3文件中的ID3V2.3部分去掉,以便在MP3机上播放 用法:mp3lcear [源mp3目录] [生成的mp3目录] &q

本文实例讲述了Python编程修改MP3文件名称的方法.分享给大家供大家参考,具体如下: 最近刚刚开始学习Python,顺便锻炼思维写的一个小函数,专门用来修改那些网上下载的mp3歌曲后名称不正确时候,使用该函数,使用方法 ModifyMp3FileInfo(r’E:/音乐/12345.mp3′) Python代码: #!修改下载的Mp3文件名称为正确的Mp3文件 def ModifyMp3FileInfo(filename): mp3Id3V1 = { “tag”:{“va

本文实例讲述了python使用PyGame播放Midi和Mp3文件的方法.分享给大家供大家参考.具体实现方法如下: ”’ pg_midi_sound101.py play midi music files (also mp3 files) using pygame tested with Python273/331 and pygame192 by vegaseat ”’ import pygame as pg def play_music(music_file): ”’ stream m

复制代码 代码如下: import sysimport urllibfrom urllib import requestimport osfrom bs4 import BeautifulSoup class DramaItem: def init(self, num, title, url): self.num = num self.title = title self.url = url def str(self):

下面利用一个python的实例程序,来学习python.这个程序的目的就是分析出所有MP3文件的Tag信息并输出. import os # 导入os模块,提供文件路径,列出文件等方法 import sys # 导入sys模块,使用sys.modules获取模块中的所有内容,类似反射的功能 from UserDict import UserDict # 这个表示从UserDict类中导入UserDict,类似于Java中的 import UserDict.UserDict def stripnul

本文实例讲述了python获取mp3文件信息的方法.分享给大家供大家参考.具体如下: 将代码生成.py文件放在目录下运行,可以获取该目录的所有mp3文件的信息,需要使用ID3库 import os, sys from ID3 import * files = os.listdir(os.getcwd()) for f in files: x = os.path.splitext(f) if x[1] == ‘.mp3’: n = x[0].split(‘ – ‘) author = n[0] t

本文实例讲述了Python写入数据到MP3文件中的方法.分享给大家供大家参考.具体分析如下: 通过Mp3的Id3V1数据段的数据来修正Mp3文件的正确名字,但是,有时候这个数据断中的数据是空的,所以这里写一个修改Id3V1数据段的数据的函数,同样是练习. 使用方法: writeMp3Header[ SongName] = ‘测试歌曲名称’ writeMp3Header[ SongPeople] = ‘不得闲’ writeMp3Header[ ZhuanJi] = ‘专辑’ writeMp3Hea

本文实例讲述了Python调用系统底层API播放wav文件的方法.分享给大家供大家参考,具体如下: 这里未使用其他库,只是使用 pywin32 调用系统底层 API 播放 wav 文件. 具体代码如下: # Our raison d’etre – playing sounds import pywintypes import struct import win32event import win32com.directsound.directsound as ds import os WAV_H

本文实例为大家分享了python3音乐播放器的关键代码,供大家参考,具体内容如下 from tkinter import * from traceback import * from win32com.client import Dispatch import time,eyed3,threading name = [] def openfile(index = [1]): global total,name filenames = filedialog.askopenfilenames(tit

本文实例讲述了Python基于pygame模块播放MP3的方法.分享给大家供大家参考,具体如下: 安装pygame(可参考:安装Python和pygame及相应的环境变量配置) pip安装这个whl文件 装完就直接跑代码啦,很短的 import time import pygame file=r’C:\Users\chan\Desktop\Adele – All I Ask.mp3′ pygame.mixer.init() print(“播放音乐1”) track = pygame.m

本文实例讲述了python使用wxPython打开并播放wav文件的方法.分享给大家供大家参考.具体实现方法如下: ”’ wx_lib_filebrowsebutton_sound.py select a sound file and play it wx.lib.filebrowsebutton.FileBrowseButton(parent, labelText, fileMask) (combines wx.TextCtrl and wxFileDialog widgets) wx.So

本文实例讲述了python通过wxPython打开一个音频文件并播放的方法.分享给大家供大家参考.具体如下: 这段代码片段使用wx.lib.filebrowsebutton.FileBrowseButton控件打开一个wav文件,使用wx.Sound播放 import wx import wx.lib.filebrowsebutton class MyFrame(wx.Frame): def init(self, parent, mytitle, mysize): wx.Frame.__

想通过编写Python代码来打开本地的.mp4格式文件,使用os模块来操作文件.我的电脑默认的是QQ影音播放器,执行Python代码打开默认播放器,播放代码中指定的视频文件. class Video(object): def init(self,path): self.path = path def play(self): from os import startfile startfile(self.path) class Movie_MP4(Video): type = ‘MP4’

用js播放.wav文件 复制代码 代码如下:

如下所示: #!/usr/bin/env python # –– coding: utf-8 –– ######################################################################## # # Copyright (c) 2017 aibot.me, Inc. All Rights Reserved # ###############################################################

本文实例讲述了delphi制作wav文件的方法.分享给大家供大家参考.具体如下: 这里delphi用waveIn…函数制作wav文件 具体代码如下: //使用窗口接受音频设备发出的消息: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button

本文所述实例为Python处理文本文件并生成指定格式文件的方法,具体实现功能代码如下所示: import os import sys import string #以指定模式打开指定文件,获取文件句柄 def getFileIns(filePath,model): print(“打开文件”) print(filePath) print(model) return open(filePath,model) #获取需要处理的文件 def getProcFile(path): return

本文实例讲述了Python实现抓取网页生成Excel文件的方法.分享给大家供大家参考,具体如下: Python抓网页,主要用到了PyQuery,这个跟jQuery用法一样,超级给力 示例代码如下: #-– encoding:utf-8 –– import sys import locale import string import traceback import datetime import urllib2 from pyquery import PyQuery as pq # 确定运行

Original: https://blog.csdn.net/weixin_29459473/article/details/112933151
Author: 网易数帆
Title: python定时播放音乐程序_python实现定时播放mp3

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/781884/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球