Skip to content

Commit

Permalink
feat(0.1.0): prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Nov 3, 2020
1 parent 039c3f5 commit 555d0db
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<br />
<p align="center">
<a href="https://github.com/littledivy/deno_audio">
<img src="./icon.webp" alt="deno_audio logo" height="240">
</a>
<h3 align="center">deno_audio</h3>

<p align="center">
Expand All @@ -21,7 +24,7 @@
## Example

```typescript
import { play } from "https://deno.land/[email protected]/mod.ts";
import { play } from "https://deno.land/x/[email protected]/mod.ts";

// supports mp3, wav, vorbis, flac
await play("music.mp3");
Expand Down Expand Up @@ -52,4 +55,6 @@ Pull request, issues and feedback are very welcome. Code style is formatted with

## Copyright

Logo by [@carazmatic](https://picsart.com/i/284157719013211) at picsart.com (cute, isn't it?)

deno_audio is licensed under the MIT license. Please see the [LICENSE](LICENSE) file.
14 changes: 7 additions & 7 deletions core_type.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @ts-ignore
export const core = Deno.core as {
ops: () => { [key: string]: number };
setAsyncHandler(rid: number, handler: (response: Uint8Array) => void): void;
dispatch(
rid: number,
msg?: any,
buf?: ArrayBufferView,
): Uint8Array | undefined;
ops: () => { [key: string]: number };
setAsyncHandler(rid: number, handler: (response: Uint8Array) => void): void;
dispatch(
rid: number,
msg?: any,
buf?: ArrayBufferView,
): Uint8Array | undefined;
};
27 changes: 13 additions & 14 deletions detect.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

export default function filename(filenameBase: string): string {
let filenameSuffix = ".so";
let filenamePrefix = "lib";
if (Deno.build.os === "windows") {
filenameSuffix = ".dll";
filenamePrefix = "";
}
if (Deno.build.os === "darwin") {
filenameSuffix = ".dylib";
}
return `${filenamePrefix}${filenameBase}${filenameSuffix}`;
}
let filenameSuffix = ".so";
let filenamePrefix = "lib";

if (Deno.build.os === "windows") {
filenameSuffix = ".dll";
filenamePrefix = "";
}
if (Deno.build.os === "darwin") {
filenameSuffix = ".dylib";
}

return `${filenamePrefix}${filenameBase}${filenameSuffix}`;
}
1 change: 0 additions & 1 deletion example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { play } from "./mod.ts";

await play("music.mp3");

Binary file added icon.webp
Binary file not shown.
19 changes: 9 additions & 10 deletions op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import "./plugin.ts";
import { core } from "./core_type.ts";

const {
play: op_play,
play: op_play,
} = core.ops();

const textDecoder = new TextDecoder();
const decoder = new TextDecoder();


export async function play(file: string) {
const encoder = new TextEncoder();
const view = encoder.encode(file);
return new Promise((resolve, reject) => {
core.setAsyncHandler(op_play, (bytes) => {
resolve(textDecoder.decode(bytes));
});
core.dispatch(op_play, view);
const encoder = new TextEncoder();
const view = encoder.encode(file);
return new Promise((resolve, reject) => {
core.setAsyncHandler(op_play, (bytes) => {
resolve(textDecoder.decode(bytes));
});
core.dispatch(op_play, view);
});
}
1 change: 0 additions & 1 deletion plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ if (isDev) {
},
});
}

0 comments on commit 555d0db

Please sign in to comment.