Skip to content

Commit

Permalink
fix slice + download
Browse files Browse the repository at this point in the history
  • Loading branch information
callmephilip committed Jun 1, 2024
1 parent 444ab3d commit dde3241
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cypress/e2e/sample-project.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ describe("sample project", () => {
cy.dcy("load-sample").click();
cy.dcy("application-waveform").should("exist");
});

it("supports downloads", () => {
cy.visit("/");
cy.dcy("load-sample").click();
cy.dcy("application-waveform").should("exist");
cy.get("[data-role=download-slice-button]").first().click();
});
});
1 change: 1 addition & 0 deletions src/components/Slices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const Slices = () => {
<span className="sr-only">Delete</span>
</Button>
<Button
data-role="download-slice-button"
onClick={(e) => {
e.stopPropagation();
sliceAudioToFile(slice);
Expand Down
4 changes: 2 additions & 2 deletions src/context/AppState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ export const AppStateProvider = ({
},
async sliceAudioToFile(slice) {
if (source!.filename) {
const slice = await ffmpeg.sliceAudio({
const s = await ffmpeg.sliceAudio({
inputFilename: source!.filename,
start: slice.start,
end: slice.end,
outputFilename: `${new Date().getTime()}.mp3`,
});
await ffmpeg.downloadFile(slice, "audio/mp3");
await ffmpeg.downloadFile(s, "audio/mp3");
}
},
async loadSampleProject() {
Expand Down

0 comments on commit dde3241

Please sign in to comment.