Skip to content

How to add MP3 background music to the slideshow #430

@nickhu168

Description

@nickhu168

source:
prs = Presentation('d:/a2.pptx')
shape = prs.slides[0].shapes.add_movie('d:/a2.mp3', 10,10,50,50);

catch exception:
Traceback (most recent call last):
File "D:\Python3\Python36\lib\site-packages\pptx\util.py", line 134, in get_prop_value
return getattr(obj, cache_attr_name)
AttributeError: '_MoviePicElementCreator' object has no attribute '__pic'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Python3\Python36\lib\site-packages\pptx\util.py", line 134, in get_prop_value
return getattr(obj, cache_attr_name)
AttributeError: '_MoviePicElementCreator' object has no attribute '__video_part_rIds'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File ".\convert.py", line 27, in
shape = prs.slides[0].shapes.add_movie('d:/media.mp3', 10,10,50,50);
File "D:\Python3\Python36\lib\site-packages\pptx\shapes\shapetree.py", line 487, in add_movie
poster_frame_image, mime_type
File "D:\Python3\Python36\lib\site-packages\pptx\shapes\shapetree.py", line 852, in new_movie_pic
mime_type
File "D:\Python3\Python36\lib\site-packages\pptx\util.py", line 136, in get_prop_value
value = f(obj)
File "D:\Python3\Python36\lib\site-packages\pptx\shapes\shapetree.py", line 869, in _pic
self._shape_id, self._shape_name, self._video_rId,
File "D:\Python3\Python36\lib\site-packages\pptx\shapes\shapetree.py", line 937, in _video_rId
return self._video_part_rIds[1]
File "D:\Python3\Python36\lib\site-packages\pptx\util.py", line 136, in get_prop_value
value = f(obj)
File "D:\Python3\Python36\lib\site-packages\pptx\shapes\shapetree.py", line 926, in _video_part_rIds
self._video
File "D:\Python3\Python36\lib\site-packages\pptx\parts\slide.py", line 188, in get_or_add_video_media_part
media_part = self._package.get_or_add_media_part(video)
File "D:\Python3\Python36\lib\site-packages\pptx\package.py", line 58, in get_or_add_media_part
return self._media_parts.get_or_add_media_part(media)
File "D:\Python3\Python36\lib\site-packages\pptx\package.py", line 214, in get_or_add_media_part
media_part = self._find_by_sha1(media.sha1)
File "D:\Python3\Python36\lib\site-packages\pptx\package.py", line 227, in _find_by_sha1
if media_part.sha1 == sha1:
AttributeError: 'Part' object has no attribute 'sha1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions