import pygame
import time
def play_music():
filepath = r"900A.mp3";
pygame.mixer.init()
# 加载音乐
pygame.mixer.music.load(filepath)
pygame.mixer.music.play(start=0.0)
# 播放时长,没有此设置,音乐不会播放,会一次性加载完
time.sleep(300)
pygame.mixer.music.stop()
play_music()
MP4
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'
movie = Movie_MP4(r'F:\Y2019\Python\ppt\ArcGIS Python入门到精通广告视频.mp4')
movie.play()
来源:oschina
链接:https://my.oschina.net/u/4287611/blog/3329457