Hi,
I am trying to add a video file to the presentation, but there seems to be something wrong with the relations used for the video element, because after I export the ppt and try to open, PowerPoint is asking me to repair the ppt. After PowerPoint repairs the file, I can see that the relations for the video tag are changed in the slide file: (r:embed="rId1")
<p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId1"/>
and also in the _rels file, the tags are the same, the only change is the relationship ID that is re-assigned after PowerPoint file repair.
When I generate the PPT, I take the video from the server and encode it in base64 and then I pass it to the data attribute of addMedia() function. I use js and not Node and for the encoding part I use XMLHttpRequest() and FileReader.readAsDataURL()
The video is successfully encoded since I can add it as the source for the HTML video tag and it's still playing, and also in the generated PPT, in the media folder I can see the video and I can play it with any video player.
Here are some parts of my code that will better define the flow that I use:
Encoding the videos:
jQuery('.elementVideo').each(function (ind, el) {
var videoPath = jQuery(el).find('source').attr('src');
var videoData = '';
var request = new XMLHttpRequest();
request.open('GET', videoPath, true);
request.responseType = 'blob';
request.onload = function () {
var reader = new FileReader();
reader.readAsDataURL(request.response);
reader.onloadend = function (e) {
videoData = e.target.result;
var elId = jQuery(el).attr('id');
// add the encoded video string to mediaArray variable for later use
mediaArray[elId] = videoData;
if (mediaDone == jQuery('.elementVideo').length) {
continueExport();
} else {
mediaDone++;
}
};
};
request.send();
});
And inside the continueExport() function I have the following for adding the video:
var elId = jQuery(el).attr('id'); // the video HTML element
var extraOptions = {
rotate: getRotationDegrees(jQuery(el))
};
var options = {
type: 'video',
data: mediaArray[elId], // the encoded video
x: pixel2inches(jQuery(el).position().left),
y: pixel2inches(jQuery(el).position().top),
w: pixel2inches(jQuery(el).width()),
h: pixel2inches(jQuery(el).height()),
// opts: extraOptions
};
slide.addMedia(options);
Also attached there are the 2 files, the generated one and the one repaired by PowerPoint:
Test Forms - Repaired.pptx
Test Forms.pptx
Any ideas would be helpful.
Thanks,
Adrian
Hi,
I am trying to add a video file to the presentation, but there seems to be something wrong with the relations used for the video element, because after I export the ppt and try to open, PowerPoint is asking me to repair the ppt. After PowerPoint repairs the file, I can see that the relations for the video tag are changed in the slide file: (r:embed="rId1")
<p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId1"/>and also in the _rels file, the tags are the same, the only change is the relationship ID that is re-assigned after PowerPoint file repair.
When I generate the PPT, I take the video from the server and encode it in base64 and then I pass it to the data attribute of addMedia() function. I use js and not Node and for the encoding part I use XMLHttpRequest() and FileReader.readAsDataURL()
The video is successfully encoded since I can add it as the source for the HTML video tag and it's still playing, and also in the generated PPT, in the media folder I can see the video and I can play it with any video player.
Here are some parts of my code that will better define the flow that I use:
Encoding the videos:
And inside the continueExport() function I have the following for adding the video:
Also attached there are the 2 files, the generated one and the one repaired by PowerPoint:
Test Forms - Repaired.pptx
Test Forms.pptx
Any ideas would be helpful.
Thanks,
Adrian