mulmocast-viewer 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md ADDED
@@ -0,0 +1,221 @@
1
+ # MulmoCast Viewer
2
+
3
+ **MulmoCast Viewer** は、mulmocast-cli で生成されたバンドル(JSON とメディアファイル群)をブラウザ上で再生・表示するための Vue 3 コンポーネントライブラリです。
4
+
5
+ ## インストール
6
+
7
+ ```bash
8
+ npm install mulmocast-viewer
9
+ # または
10
+ yarn add mulmocast-viewer
11
+ ```
12
+
13
+ ## 使い方
14
+
15
+ ### 基本的な使用方法
16
+
17
+ MulmoViewer コンポーネントを Vue アプリケーションで簡単に利用できます。
18
+
19
+ #### デフォルトUI(ボタン付き)
20
+
21
+ ```vue
22
+ <template>
23
+ <div>
24
+ <MulmoViewer
25
+ :data-set="data"
26
+ :base-path="basePath"
27
+ :audio-lang="audioLang"
28
+ :text-lang="textLang"
29
+ />
30
+ <div>
31
+ Audio: <SelectLanguage v-model="audioLang" />
32
+ Text: <SelectLanguage v-model="textLang" />
33
+ </div>
34
+ </div>
35
+ </template>
36
+
37
+ <script setup lang="ts">
38
+ import { ref } from 'vue'
39
+ import { MulmoViewer, SelectLanguage } from 'mulmocast-viewer'
40
+ import 'mulmocast-viewer/style.css'
41
+
42
+ import data from './path/to/mulmo_view.json'
43
+ const basePath = '/media_bundle'
44
+ const audioLang = ref('en')
45
+ const textLang = ref('en')
46
+ </script>
47
+ ```
48
+
49
+ #### カスタムUIの作成
50
+
51
+ スロットを使用してナビゲーションボタンやレイアウトを自由にカスタマイズできます。
52
+
53
+ ```vue
54
+ <template>
55
+ <MulmoViewer
56
+ :data-set="data"
57
+ :base-path="basePath"
58
+ :audio-lang="audioLang"
59
+ :text-lang="textLang"
60
+ v-slot="{ MulmoPlayer, pageProps, pageMove, currentPage, pageCount }"
61
+ >
62
+ <div class="my-custom-layout">
63
+ <button @click="pageMove(-1)" :disabled="currentPage === 0">
64
+ ← 前へ
65
+ </button>
66
+
67
+ <MulmoPlayer v-bind="pageProps" />
68
+
69
+ <button @click="pageMove(1)" :disabled="currentPage >= pageCount - 1">
70
+ 次へ →
71
+ </button>
72
+
73
+ <div class="page-info">
74
+ {{ currentPage + 1 }} / {{ pageCount }}
75
+ </div>
76
+ </div>
77
+ </MulmoViewer>
78
+ </template>
79
+
80
+ <script setup lang="ts">
81
+ import { ref } from 'vue'
82
+ import { MulmoViewer } from 'mulmocast-viewer'
83
+ import 'mulmocast-viewer/style.css'
84
+
85
+ import data from './path/to/mulmo_view.json'
86
+ const basePath = '/media_bundle'
87
+ const audioLang = ref('en')
88
+ const textLang = ref('en')
89
+ </script>
90
+ ```
91
+
92
+ ## セットアップ手順
93
+
94
+ ### 1. mulmocast-cli でバンドルを作成
95
+
96
+ ```bash
97
+ mulmocast bundle path/to/your/file.json
98
+ ```
99
+
100
+ ### 2. 生成されたフォルダを配置
101
+
102
+ 生成されたバンドルフォルダを、プロジェクトの公開ディレクトリに配置します。
103
+
104
+ - Vue プロジェクト: `/public/media_bundle/`
105
+ - その他: 任意の公開ディレクトリ
106
+
107
+ ディレクトリ名は自由に変更できます(例: `/public/demo_bundle/`)。
108
+
109
+ ### 3. JSON データの読み込み
110
+
111
+ `mulmo_view.json` を以下のいずれかの方法で読み込みます:
112
+
113
+ #### 方法 1: 直接インポート
114
+
115
+ ```typescript
116
+ import data from './path/to/mulmo_view.json'
117
+ ```
118
+
119
+ #### 方法 2: 動的読み込み
120
+
121
+ ```typescript
122
+ const response = await fetch('/media_bundle/mulmo_view.json')
123
+ const data = await response.json()
124
+ ```
125
+
126
+ ### 4. basePath の設定
127
+
128
+ `basePath` には、メディアファイルが配置されているディレクトリまたは URL を指定します。
129
+
130
+ ```typescript
131
+ // ローカルパスの例
132
+ const basePath = '/media_bundle'
133
+
134
+ // 外部 URL の例
135
+ const basePath = 'https://example.com/bundle_demo'
136
+ ```
137
+
138
+ MulmoViewer は、この `basePath` を基準に画像・音声・動画などのメディアファイルを相対的に参照します。
139
+
140
+ ## API リファレンス
141
+
142
+ ### Props
143
+
144
+ | Prop | Type | Required | Default | Description |
145
+ |------|------|----------|---------|-------------|
146
+ | `dataSet` | `ViewerData` | Yes | - | mulmo_view.json から読み込んだデータ |
147
+ | `basePath` | `string` | Yes | - | メディアファイルのベースパス(ローカルまたは URL) |
148
+ | `initPage` | `number` | No | `0` | 初期表示ページ |
149
+ | `audioLang` | `string` | No | `'en'` | 音声言語 |
150
+ | `textLang` | `string` | No | `'en'` | テキスト言語 |
151
+
152
+ ### Events
153
+
154
+ | Event | Parameters | Description |
155
+ |-------|------------|-------------|
156
+ | `updatedPage` | `nextPage: number` | ページが変更されたときに発火 |
157
+
158
+ ### Slot Props(カスタムUI作成時)
159
+
160
+ デフォルトスロットで以下のプロパティとコンポーネントが利用可能です:
161
+
162
+ | Prop | Type | Description |
163
+ |------|------|-------------|
164
+ | `MulmoPlayer` | `Component` | プレイヤーコンポーネント(メディア表示用) |
165
+ | `pageProps` | `Object` | MulmoPlayer コンポーネントに渡す props |
166
+ | `currentPage` | `number` | 現在のページ番号(0始まり) |
167
+ | `pageCount` | `number` | 総ページ数 |
168
+ | `pageMove` | `(delta: number) => boolean` | ページ移動関数(-1: 前へ、1: 次へ) |
169
+ | `isPlaying` | `boolean` | メディアが再生中かどうか |
170
+ | `audioLang` | `Ref<string>` | 音声言語(変更可能) |
171
+ | `textLang` | `Ref<string>` | テキスト言語(変更可能) |
172
+ | `SelectLanguage` | `Component` | 言語選択コンポーネント |
173
+
174
+ ## 開発者向け
175
+
176
+ このリポジトリは、ビューアコンポーネントの開発環境を提供しています。
177
+
178
+ ### 開発環境のセットアップ
179
+
180
+ 1. **バンドルを作成**
181
+
182
+ ```bash
183
+ mulmocast bundle scripts/foo/bar.json
184
+ ```
185
+
186
+ 2. **生成されたフォルダを配置**
187
+
188
+ バンドルフォルダを `public/` 以下に配置します。以下のようなパスになるようにしてください:
189
+
190
+ ```
191
+ public/bar/mulmo_view.json
192
+ ```
193
+
194
+ 3. **データリストを更新**
195
+
196
+ ```bash
197
+ yarn run fileList
198
+ ```
199
+
200
+ 4. **開発サーバを起動**
201
+
202
+ ```bash
203
+ yarn run dev
204
+ ```
205
+
206
+ ### ビルド
207
+
208
+ ```bash
209
+ # ライブラリビルド
210
+ yarn run build:lib
211
+
212
+ # アプリケーションビルド
213
+ yarn run build:app
214
+
215
+ # 両方をビルド
216
+ yarn run build
217
+ ```
218
+
219
+ ## ライセンス
220
+
221
+ MIT
package/README.md CHANGED
@@ -1,28 +1,221 @@
1
1
  # MulmoCast Viewer
2
2
 
3
+ **MulmoCast Viewer** is a Vue 3 component library for playing and displaying bundles (JSON and media files) generated by mulmocast-cli in a browser.
3
4
 
4
- ### cliでbundleを作る
5
+ ## Installation
5
6
 
7
+ ```bash
8
+ npm install mulmocast-viewer
9
+ # or
10
+ yarn add mulmocast-viewer
6
11
  ```
7
- yarn run cli bundle scripts/foo/bar.json
12
+
13
+ ## Usage
14
+
15
+ ### Basic Usage
16
+
17
+ You can easily use the MulmoViewer component in your Vue application.
18
+
19
+ #### Default UI (with navigation buttons)
20
+
21
+ ```vue
22
+ <template>
23
+ <div>
24
+ <MulmoViewer
25
+ :data-set="data"
26
+ :base-path="basePath"
27
+ :audio-lang="audioLang"
28
+ :text-lang="textLang"
29
+ />
30
+ <div>
31
+ Audio: <SelectLanguage v-model="audioLang" />
32
+ Text: <SelectLanguage v-model="textLang" />
33
+ </div>
34
+ </div>
35
+ </template>
36
+
37
+ <script setup lang="ts">
38
+ import { ref } from 'vue'
39
+ import { MulmoViewer, SelectLanguage } from 'mulmocast-viewer'
40
+ import 'mulmocast-viewer/style.css'
41
+
42
+ import data from './path/to/mulmo_view.json'
43
+ const basePath = '/media_bundle'
44
+ const audioLang = ref('en')
45
+ const textLang = ref('en')
46
+ </script>
8
47
  ```
9
48
 
10
- ### 作成したfolderをviewerのpublic以下に配置する
49
+ #### Custom UI
50
+
51
+ You can customize navigation buttons and layout using slots.
11
52
 
12
- 重要なのは、以下のようなpathにmulmo_view.jsonが配置されているかどうかです。
53
+ ```vue
54
+ <template>
55
+ <MulmoViewer
56
+ :data-set="data"
57
+ :base-path="basePath"
58
+ :audio-lang="audioLang"
59
+ :text-lang="textLang"
60
+ v-slot="{ MulmoPlayer, pageProps, pageMove, currentPage, pageCount }"
61
+ >
62
+ <div class="my-custom-layout">
63
+ <button @click="pageMove(-1)" :disabled="currentPage === 0">
64
+ ← Previous
65
+ </button>
13
66
 
67
+ <MulmoPlayer v-bind="pageProps" />
68
+
69
+ <button @click="pageMove(1)" :disabled="currentPage >= pageCount - 1">
70
+ Next →
71
+ </button>
72
+
73
+ <div class="page-info">
74
+ {{ currentPage + 1 }} / {{ pageCount }}
75
+ </div>
76
+ </div>
77
+ </MulmoViewer>
78
+ </template>
79
+
80
+ <script setup lang="ts">
81
+ import { ref } from 'vue'
82
+ import { MulmoViewer } from 'mulmocast-viewer'
83
+ import 'mulmocast-viewer/style.css'
84
+
85
+ import data from './path/to/mulmo_view.json'
86
+ const basePath = '/media_bundle'
87
+ const audioLang = ref('en')
88
+ const textLang = ref('en')
89
+ </script>
14
90
  ```
15
- public/bar/mulmo_view.json
91
+
92
+ ## Setup Guide
93
+
94
+ ### 1. Create a Bundle with mulmocast-cli
95
+
96
+ ```bash
97
+ mulmocast bundle path/to/your/file.json
16
98
  ```
17
99
 
18
- ### DataListを更新する
100
+ ### 2. Place the Generated Folder
19
101
 
102
+ Place the generated bundle folder in your project's public directory.
103
+
104
+ - Vue projects: `/public/media_bundle/`
105
+ - Other projects: Any public directory
106
+
107
+ You can freely change the directory name (e.g., `/public/demo_bundle/`).
108
+
109
+ ### 3. Load JSON Data
110
+
111
+ Load `mulmo_view.json` using one of the following methods:
112
+
113
+ #### Method 1: Direct Import
114
+
115
+ ```typescript
116
+ import data from './path/to/mulmo_view.json'
20
117
  ```
21
- yarn run fileList
118
+
119
+ #### Method 2: Dynamic Loading
120
+
121
+ ```typescript
122
+ const response = await fetch('/media_bundle/mulmo_view.json')
123
+ const data = await response.json()
124
+ ```
125
+
126
+ ### 4. Configure basePath
127
+
128
+ Set `basePath` to the directory or URL where media files are located.
129
+
130
+ ```typescript
131
+ // Local path example
132
+ const basePath = '/media_bundle'
133
+
134
+ // External URL example
135
+ const basePath = 'https://example.com/bundle_demo'
136
+ ```
137
+
138
+ MulmoViewer references media files (images, audio, video) relative to this `basePath`.
139
+
140
+ ## API Reference
141
+
142
+ ### Props
143
+
144
+ | Prop | Type | Required | Default | Description |
145
+ |------|------|----------|---------|-------------|
146
+ | `dataSet` | `ViewerData` | Yes | - | Data loaded from mulmo_view.json |
147
+ | `basePath` | `string` | Yes | - | Base path for media files (local or URL) |
148
+ | `initPage` | `number` | No | `0` | Initial page to display |
149
+ | `audioLang` | `string` | No | `'en'` | Audio language |
150
+ | `textLang` | `string` | No | `'en'` | Text language |
151
+
152
+ ### Events
153
+
154
+ | Event | Parameters | Description |
155
+ |-------|------------|-------------|
156
+ | `updatedPage` | `nextPage: number` | Emitted when the page is changed |
157
+
158
+ ### Slot Props (for Custom UI)
159
+
160
+ The default slot exposes the following properties and components:
161
+
162
+ | Prop | Type | Description |
163
+ |------|------|-------------|
164
+ | `MulmoPlayer` | `Component` | Player component for displaying media |
165
+ | `pageProps` | `Object` | Props to pass to the MulmoPlayer component |
166
+ | `currentPage` | `number` | Current page number (0-indexed) |
167
+ | `pageCount` | `number` | Total number of pages |
168
+ | `pageMove` | `(delta: number) => boolean` | Function to move pages (-1: previous, 1: next) |
169
+ | `isPlaying` | `boolean` | Whether media is currently playing |
170
+ | `audioLang` | `Ref<string>` | Audio language (mutable) |
171
+ | `textLang` | `Ref<string>` | Text language (mutable) |
172
+ | `SelectLanguage` | `Component` | Language selection component |
173
+
174
+ ## For Developers
175
+
176
+ This repository provides a development environment for the viewer component.
177
+
178
+ ### Development Environment Setup
179
+
180
+ 1. **Create a Bundle**
181
+
182
+ ```bash
183
+ mulmocast bundle scripts/foo/bar.json
22
184
  ```
23
185
 
24
- ### サーバを起動する
186
+ 2. **Place the Generated Folder**
187
+
188
+ Place the bundle folder under `public/`. Ensure the path looks like this:
25
189
 
26
190
  ```
191
+ public/bar/mulmo_view.json
192
+ ```
193
+
194
+ 3. **Update Data List**
195
+
196
+ ```bash
197
+ yarn run fileList
198
+ ```
199
+
200
+ 4. **Start Development Server**
201
+
202
+ ```bash
27
203
  yarn run dev
28
- ```
204
+ ```
205
+
206
+ ### Build
207
+
208
+ ```bash
209
+ # Library build
210
+ yarn run build:lib
211
+
212
+ # Application build
213
+ yarn run build:app
214
+
215
+ # Build both
216
+ yarn run build
217
+ ```
218
+
219
+ ## License
220
+
221
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { default as MulmoView } from './components/viewer.vue';
2
- import { default as i18n } from './i18n';
3
- export { MulmoView, i18n };
1
+ import { default as MulmoViewer } from './components/mulmo_viewer.vue';
2
+ import { default as SelectLanguage } from './components/select_language.vue';
3
+ export { MulmoViewer, SelectLanguage };
@@ -1,13 +1,12 @@
1
- import { defineComponent as W, ref as c, createElementBlock as m, openBlock as r, createTextVNode as j, createElementVNode as v, createCommentVNode as $, toDisplayString as R, unref as L, Fragment as G, renderList as U, computed as h, createVNode as T, withDirectives as H, createBlock as J, vShow as K } from "vue";
2
- import { useI18n as O, createI18n as q } from "vue-i18n";
3
- const D = async (e) => await new Promise((g) => setTimeout(g, e)), Q = { class: "items-center justify-center w-full" }, X = { key: 0 }, Y = ["src"], Z = {
1
+ import { defineComponent as R, ref as m, createElementBlock as d, openBlock as l, createTextVNode as z, createElementVNode as c, createCommentVNode as $, toDisplayString as j, Fragment as C, renderList as I, computed as P, renderSlot as O, withDirectives as q, normalizeProps as T, guardReactiveProps as G, createVNode as H, mergeProps as W, unref as J, createBlock as K, vShow as Q } from "vue";
2
+ const N = async (t) => await new Promise((S) => setTimeout(S, t)), U = { class: "items-center justify-center w-full" }, X = { key: 0 }, Y = ["src"], Z = {
4
3
  key: 1,
5
4
  class: "relative inline-block"
6
- }, ee = ["src"], ae = ["src"], oe = { key: 2 }, te = ["src", "poster"], ue = {
5
+ }, ee = ["src"], ae = ["src"], te = { key: 2 }, oe = ["src", "poster"], ue = {
7
6
  key: 3,
8
7
  class: "relative inline-block"
9
- }, ne = ["src"], le = { key: 4 }, ie = "https://github.com/receptron/mulmocast-cli/blob/main/assets/images/mulmocast_credit.png?raw=true", M = /* @__PURE__ */ W({
10
- __name: "page",
8
+ }, ne = ["src"], ie = { key: 4 }, le = "https://github.com/receptron/mulmocast-cli/blob/main/assets/images/mulmocast_credit.png?raw=true", L = /* @__PURE__ */ R({
9
+ __name: "mulmo_player",
11
10
  props: {
12
11
  index: {},
13
12
  videoWithAudioSource: {},
@@ -19,276 +18,215 @@ const D = async (e) => await new Promise((g) => setTimeout(g, e)), Q = { class:
19
18
  duration: {}
20
19
  },
21
20
  emits: ["play", "pause", "ended"],
22
- setup(e, { expose: g, emit: P }) {
23
- const { t: l } = O(), b = e, i = P, a = c(), o = c(), u = c(), s = c(), x = c(), S = () => {
24
- u.value && o.value && (u.value.currentTime = o.value.currentTime, u.value.currentTime === o.value.currentTime && u.value.play()), i("play");
25
- }, n = (d) => {
26
- !o.value?.ended && u?.value && u.value?.pause(), console.log(d), p(d);
27
- }, _ = () => {
28
- !u.value?.paused && !u.value?.ended && (u.value?.currentTime ?? 0) > 0 || y();
29
- }, E = () => {
30
- !o.value?.paused && !o.value?.ended && (o.value?.currentTime ?? 0) > 0 || y();
31
- }, V = () => {
32
- i("play");
33
- }, p = (d) => {
34
- const k = d.target;
35
- k.duration !== k.currentTime && i("pause");
36
- }, y = () => {
37
- i("ended");
21
+ setup(t, { expose: S, emit: b }) {
22
+ const u = t, s = b, n = m(), a = m(), o = m(), f = m(), g = m(), p = () => {
23
+ o.value && a.value && (o.value.currentTime = a.value.currentTime, o.value.currentTime === a.value.currentTime && o.value.play()), s("play");
24
+ }, _ = (v) => {
25
+ !a.value?.ended && o?.value && o.value?.pause(), console.log(v), k(v);
26
+ }, w = () => {
27
+ !o.value?.paused && !o.value?.ended && (o.value?.currentTime ?? 0) > 0 || x();
28
+ }, r = () => {
29
+ !a.value?.paused && !a.value?.ended && (a.value?.currentTime ?? 0) > 0 || x();
30
+ }, h = () => {
31
+ s("play");
32
+ }, k = (v) => {
33
+ const y = v.target;
34
+ y.duration !== y.currentTime && s("pause");
35
+ }, x = () => {
36
+ s("ended");
38
37
  };
39
- return g({
38
+ return S({
40
39
  play: async () => {
41
- a.value && a.value.play(), o.value && o.value.play(), s.value && s.value.play(), !a.value && !o.value && !s.value && (await D((b.duration ?? 0) * 1e3), i("ended"));
40
+ n.value && n.value.play(), a.value && a.value.play(), f.value && f.value.play(), !n.value && !a.value && !f.value && (await N((u.duration ?? 0) * 1e3), s("ended"));
42
41
  }
43
- }), (d, k) => (r(), m("div", Q, [
44
- e.videoWithAudioSource ? (r(), m("div", X, [
45
- v("video", {
42
+ }), (v, y) => (l(), d("div", U, [
43
+ t.videoWithAudioSource ? (l(), d("div", X, [
44
+ c("video", {
46
45
  ref_key: "videoWithAudioRef",
47
- ref: a,
48
- src: e.videoWithAudioSource,
46
+ ref: n,
47
+ src: t.videoWithAudioSource,
49
48
  class: "mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",
50
49
  controls: !0,
51
50
  playsinline: "true",
52
- onPlay: V,
53
- onPause: p,
54
- onEnded: y
51
+ onPlay: h,
52
+ onPause: k,
53
+ onEnded: x
55
54
  }, null, 40, Y)
56
- ])) : e.soundEffectSource || e.videoSource ? (r(), m("div", Z, [
57
- v("video", {
55
+ ])) : t.soundEffectSource || t.videoSource ? (l(), d("div", Z, [
56
+ c("video", {
58
57
  ref_key: "videoRef",
59
- ref: o,
58
+ ref: a,
60
59
  class: "mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",
61
- src: e.soundEffectSource || e.videoSource,
60
+ src: t.soundEffectSource || t.videoSource,
62
61
  controls: !0,
63
62
  playsinline: "true",
64
- onPlay: S,
65
- onPause: n,
66
- onEnded: _
63
+ onPlay: p,
64
+ onPause: _,
65
+ onEnded: w
67
66
  }, null, 40, ee),
68
- e.audioSource ? (r(), m("audio", {
67
+ t.audioSource ? (l(), d("audio", {
69
68
  key: 0,
70
69
  ref_key: "audioSyncRef",
71
- ref: u,
72
- src: e.audioSource,
70
+ ref: o,
71
+ src: t.audioSource,
73
72
  controls: !0,
74
73
  class: "hidden",
75
- onEnded: E
74
+ onEnded: r
76
75
  }, null, 40, ae)) : $("", !0)
77
- ])) : e.audioSource ? (r(), m("div", oe, [
78
- v("video", {
76
+ ])) : t.audioSource ? (l(), d("div", te, [
77
+ c("video", {
79
78
  ref_key: "audioRef",
80
- ref: s,
79
+ ref: f,
81
80
  class: "mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",
82
- src: e.audioSource,
83
- poster: e.imageSource ?? ie,
81
+ src: t.audioSource,
82
+ poster: t.imageSource ?? le,
84
83
  controls: !0,
85
84
  playsinline: "true",
86
- onPlay: V,
87
- onPause: p,
88
- onEnded: y
89
- }, null, 40, te)
90
- ])) : e.imageSource ? (r(), m("div", ue, [
91
- v("img", {
85
+ onPlay: h,
86
+ onPause: k,
87
+ onEnded: x
88
+ }, null, 40, oe)
89
+ ])) : t.imageSource ? (l(), d("div", ue, [
90
+ c("img", {
92
91
  ref_key: "imageRef",
93
- ref: x,
94
- src: e.imageSource,
92
+ ref: g,
93
+ src: t.imageSource,
95
94
  class: "max-w-full max-h-full object-contain"
96
95
  }, null, 8, ne)
97
- ])) : (r(), m("div", le, R(L(l)("ui.common.noMedia")), 1)),
98
- j(" " + R(e.text), 1)
96
+ ])) : (l(), d("div", ie, "No media available")),
97
+ z(" " + j(t.text), 1)
99
98
  ]));
100
99
  }
101
- }), se = ["value"], de = ["value"], B = /* @__PURE__ */ W({
100
+ }), se = ["value"], de = ["value"], ce = /* @__PURE__ */ R({
102
101
  __name: "select_language",
103
102
  props: {
104
103
  modelValue: {}
105
104
  },
106
105
  emits: ["update:modelValue"],
107
- setup(e, { emit: g }) {
108
- const P = ["en", "ja"], l = g, b = (i) => {
109
- const a = i.target;
110
- l("update:modelValue", a.value);
106
+ setup(t, { emit: S }) {
107
+ const b = ["en", "ja"], u = S, s = (n) => {
108
+ const a = n.target;
109
+ u("update:modelValue", a.value);
111
110
  };
112
- return (i, a) => (r(), m("select", {
113
- value: e.modelValue,
114
- onChange: b
111
+ return (n, a) => (l(), d("select", {
112
+ value: t.modelValue,
113
+ onChange: s
115
114
  }, [
116
- (r(), m(G, null, U(P, (o) => v("option", {
115
+ (l(), d(C, null, I(b, (o) => c("option", {
117
116
  key: o,
118
117
  value: o
119
- }, R(o), 9, de)), 64))
118
+ }, j(o), 9, de)), 64))
120
119
  ], 40, se));
121
120
  }
122
- }), ce = { class: "w-full overflow-hidden" }, re = { class: "max-w-7xl mx-auto px-4" }, ve = { class: "flex items-center justify-between" }, me = ["disabled"], fe = { class: "px-4" }, ge = ["src"], he = ["disabled"], xe = /* @__PURE__ */ W({
123
- __name: "viewer",
121
+ }), re = { class: "w-full overflow-hidden" }, ve = { class: "max-w-7xl mx-auto px-4" }, me = { class: "flex items-center justify-between" }, ge = ["disabled"], fe = { class: "px-4" }, he = ["disabled"], ye = ["src"], Pe = /* @__PURE__ */ R({
122
+ __name: "mulmo_viewer",
124
123
  props: {
125
124
  dataSet: {},
126
125
  basePath: {},
127
- initPage: {}
126
+ initPage: {},
127
+ audioLang: { default: "en" },
128
+ textLang: { default: "en" }
128
129
  },
129
- emits: ["updatedPage"],
130
- setup(e, { expose: g, emit: P }) {
131
- const l = e, b = P, i = l.dataSet?.beats?.length ?? 0, a = c(l.initPage ?? 0), o = c(!0), u = c(), s = c(), x = c("en"), S = c("ja"), n = h(() => l.dataSet?.beats[a.value]), _ = h(() => n.value?.videoWithAudioSource ? l.basePath + "/" + n.value.videoWithAudioSource : ""), E = h(() => n.value?.soundEffectSource ? l.basePath + "/" + n.value.soundEffectSource : ""), V = h(() => n.value?.videoSource ? l.basePath + "/" + n.value.videoSource : ""), p = h(() => {
132
- const f = n.value?.audioSources?.[S.value];
133
- return f ? l.basePath + "/" + f : "";
134
- }), y = h(() => n.value?.imageSource ? l.basePath + "/" + n.value.imageSource : ""), C = h(() => n.value?.multiLinguals?.[x.value] ?? n.value?.text ?? ""), d = c(!1), k = () => {
135
- d.value = !0, s.value && s.value.play();
136
- }, I = () => {
137
- console.log("pause"), d.value = !1, s.value && s.value.pause();
138
- }, N = async () => {
139
- await D(500), u.value && u.value.play();
140
- }, F = (f) => {
141
- a.value !== f && (a.value = f, d.value && o.value && N());
142
- }, A = (f) => {
143
- const t = a.value + f;
144
- return t > -1 && t < i ? (F(t), b("updatedPage", t), !0) : !1;
145
- }, z = () => {
146
- console.log("end"), d.value = !1, o.value && A(1) ? N() : s.value && s.value.pause();
147
- };
148
- return g({
149
- updatePage: F
150
- }), (f, t) => (r(), m("div", ce, [
151
- v("div", re, [
152
- v("div", ve, [
153
- v("button", {
154
- class: "px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",
155
- disabled: a.value === 0,
156
- onClick: t[0] || (t[0] = (w) => A(-1))
157
- }, " Prev ", 8, me),
158
- v("div", fe, [
159
- T(M, {
160
- ref_key: "mediaPlayer",
161
- ref: u,
162
- "video-with-audio-source": _.value,
163
- "video-source": V.value,
164
- "sound-effect-source": E.value,
165
- "audio-source": p.value,
166
- "image-source": y.value,
167
- index: a.value,
168
- text: C.value,
169
- duration: n.value?.duration,
170
- onPlay: k,
171
- onPause: I,
172
- onEnded: z
173
- }, null, 8, ["video-with-audio-source", "video-source", "sound-effect-source", "audio-source", "image-source", "index", "text", "duration"]),
174
- a.value + 1 < L(i) ? H((r(), J(M, {
175
- key: 0,
176
- data: e.dataSet?.beats[a.value + 1],
177
- "base-path": e.basePath,
178
- index: a.value + 1
179
- }, null, 8, ["data", "base-path", "index"])), [
180
- [K, !1]
181
- ]) : $("", !0)
182
- ]),
183
- e.dataSet?.bgmFile ? (r(), m("audio", {
184
- key: 0,
185
- ref_key: "bgmRef",
186
- ref: s,
187
- src: e.dataSet?.bgmFile
188
- }, null, 8, ge)) : $("", !0),
189
- v("button", {
190
- class: "px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",
191
- disabled: a.value >= L(i) - 1,
192
- onClick: t[1] || (t[1] = (w) => A(1))
193
- }, " Next ", 8, he)
130
+ emits: ["updatedPage", "update:audioLang", "update:textLang"],
131
+ setup(t, { expose: S, emit: b }) {
132
+ const u = t, s = b, n = u.dataSet?.beats?.length ?? 0, a = m(u.initPage ?? 0), o = m(!0), f = m(), g = m(), p = P({
133
+ get: () => u.audioLang,
134
+ set: (e) => s("update:audioLang", e || "en")
135
+ }), _ = P({
136
+ get: () => u.textLang,
137
+ set: (e) => s("update:textLang", e || "en")
138
+ }), w = P(() => u.dataSet?.beats[a.value]), r = (e) => e ? u.basePath + "/" + e : "", h = m(!1), k = () => {
139
+ h.value = !0, g.value && g.value.play();
140
+ }, x = () => {
141
+ console.log("pause"), h.value = !1, g.value && g.value.pause();
142
+ }, E = async () => {
143
+ await N(500), f.value && f.value.play();
144
+ }, v = (e) => {
145
+ a.value !== e && (a.value = e, h.value && o.value && E());
146
+ }, y = (e) => {
147
+ const i = a.value + e;
148
+ return i > -1 && i < n ? (v(i), s("updatedPage", i), !0) : !1;
149
+ }, D = () => {
150
+ console.log("end"), h.value = !1, o.value && y(1) ? E() : g.value && g.value.pause();
151
+ }, V = P(() => {
152
+ const e = w.value, i = e?.audioSources?.[p.value];
153
+ return {
154
+ videoWithAudioSource: r(e?.videoWithAudioSource),
155
+ videoSource: r(e?.videoSource),
156
+ soundEffectSource: r(e?.soundEffectSource),
157
+ audioSource: i ? u.basePath + "/" + i : "",
158
+ imageSource: r(e?.imageSource),
159
+ index: a.value,
160
+ text: e?.multiLinguals?.[_.value] ?? e?.text ?? "",
161
+ duration: e?.duration,
162
+ onPlay: k,
163
+ onPause: x,
164
+ onEnded: D
165
+ };
166
+ }), F = P(() => u.dataSet?.beats[a.value + 1]), A = P(() => {
167
+ if (a.value + 1 >= n) return null;
168
+ const e = F.value;
169
+ return {
170
+ videoWithAudioSource: r(e?.videoWithAudioSource),
171
+ videoSource: r(e?.videoSource),
172
+ soundEffectSource: r(e?.soundEffectSource),
173
+ audioSource: e?.audioSources?.[p.value] ? u.basePath + "/" + e.audioSources[p.value] : "",
174
+ imageSource: r(e?.imageSource),
175
+ index: a.value + 1,
176
+ text: e?.multiLinguals?.[_.value] ?? e?.text ?? "",
177
+ duration: e?.duration
178
+ };
179
+ }), M = P(() => ({
180
+ MulmoPlayer: L,
181
+ pageProps: V.value,
182
+ currentPage: a.value,
183
+ pageCount: n,
184
+ pageMove: y,
185
+ isPlaying: h.value,
186
+ audioLang: p,
187
+ textLang: _,
188
+ SelectLanguage: ce
189
+ }));
190
+ return S({
191
+ updatePage: v
192
+ }), (e, i) => (l(), d(C, null, [
193
+ O(e.$slots, "default", T(G(M.value)), () => [
194
+ c("div", re, [
195
+ c("div", ve, [
196
+ c("div", me, [
197
+ c("button", {
198
+ class: "px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",
199
+ disabled: a.value === 0,
200
+ onClick: i[0] || (i[0] = (B) => y(-1))
201
+ }, " Prev ", 8, ge),
202
+ c("div", fe, [
203
+ H(L, W({
204
+ ref_key: "mediaPlayer",
205
+ ref: f
206
+ }, V.value), null, 16)
207
+ ]),
208
+ c("button", {
209
+ class: "px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",
210
+ disabled: a.value >= J(n) - 1,
211
+ onClick: i[1] || (i[1] = (B) => y(1))
212
+ }, " Next ", 8, he)
213
+ ])
214
+ ])
194
215
  ])
195
216
  ]),
196
- v("div", null, [
197
- t[4] || (t[4] = j("Audio: ", -1)),
198
- T(B, {
199
- modelValue: S.value,
200
- "onUpdate:modelValue": t[2] || (t[2] = (w) => S.value = w)
201
- }, null, 8, ["modelValue"])
202
- ]),
203
- v("div", null, [
204
- t[5] || (t[5] = j("Text: ", -1)),
205
- T(B, {
206
- modelValue: x.value,
207
- "onUpdate:modelValue": t[3] || (t[3] = (w) => x.value = w)
208
- }, null, 8, ["modelValue"])
209
- ])
210
- ]));
211
- }
212
- }), ye = {
213
- en: {
214
- message: {
215
- hello: "Hello"
216
- },
217
- ui: {
218
- common: {
219
- noLang: "No language available",
220
- noMedia: "No media available"
221
- },
222
- actions: {
223
- translate: "Translate",
224
- generateAudio: "Generate Audio"
225
- }
226
- },
227
- mulmoViewer: {
228
- text: "Text",
229
- audio: "Audio"
230
- },
231
- project: {
232
- productTabs: {
233
- slide: {
234
- autoPlay: "Auto Play",
235
- details: "{current} / {pages}"
236
- }
237
- }
238
- },
239
- languages: {
240
- en: "English",
241
- ja: "Japanese",
242
- zh: "Chinese",
243
- ko: "Korean",
244
- es: "Spanish",
245
- fr: "French",
246
- de: "German"
247
- }
248
- },
249
- ja: {
250
- message: {
251
- hello: "こんにちは"
252
- },
253
- ui: {
254
- common: {
255
- noLang: "言語がありません",
256
- noMedia: "メディアがありません"
257
- },
258
- actions: {
259
- translate: "翻訳",
260
- generateAudio: "音声を生成"
261
- }
262
- },
263
- mulmoViewer: {
264
- text: "テキスト",
265
- audio: "音声"
266
- },
267
- project: {
268
- productTabs: {
269
- slide: {
270
- autoPlay: "自動再生",
271
- details: "{current} / {pages}"
272
- }
273
- }
274
- },
275
- languages: {
276
- en: "英語",
277
- ja: "日本語",
278
- zh: "中国語",
279
- ko: "韓国語",
280
- es: "スペイン語",
281
- fr: "フランス語",
282
- de: "ドイツ語"
283
- }
217
+ A.value ? q((l(), K(L, T(W({ key: 0 }, A.value)), null, 16)), [
218
+ [Q, !1]
219
+ ]) : $("", !0),
220
+ t.dataSet?.bgmFile ? (l(), d("audio", {
221
+ key: 1,
222
+ ref_key: "bgmRef",
223
+ ref: g,
224
+ src: t.dataSet?.bgmFile
225
+ }, null, 8, ye)) : $("", !0)
226
+ ], 64));
284
227
  }
285
- }, Se = q({
286
- legacy: !1,
287
- locale: "en",
288
- fallbackLocale: "en",
289
- messages: ye
290
228
  });
291
229
  export {
292
- xe as MulmoView,
293
- Se as i18n
230
+ Pe as MulmoViewer,
231
+ ce as SelectLanguage
294
232
  };
@@ -1 +1 @@
1
- (function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-i18n")):typeof define=="function"&&define.amd?define(["exports","vue","vue-i18n"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r["mulmoast-viewer"]={},r.Vue,r.VueI18n))})(this,(function(r,e,w){"use strict";const B=async t=>await new Promise(f=>setTimeout(f,t)),$={class:"items-center justify-center w-full"},R={key:0},C=["src"],L={key:1,class:"relative inline-block"},W=["src"],M=["src"],D={key:2},F=["src","poster"],I={key:3,class:"relative inline-block"},q=["src"],z={key:4},G="https://github.com/receptron/mulmocast-cli/blob/main/assets/images/mulmocast_credit.png?raw=true",N=e.defineComponent({__name:"page",props:{index:{},videoWithAudioSource:{},soundEffectSource:{},videoSource:{},imageSource:{},audioSource:{},text:{},duration:{}},emits:["play","pause","ended"],setup(t,{expose:f,emit:h}){const{t:d}=w.useI18n(),y=t,c=h,o=e.ref(),a=e.ref(),l=e.ref(),s=e.ref(),v=e.ref(),p=()=>{l.value&&a.value&&(l.value.currentTime=a.value.currentTime,l.value.currentTime===a.value.currentTime&&l.value.play()),c("play")},i=u=>{!a.value?.ended&&l?.value&&l.value?.pause(),console.log(u),k(u)},b=()=>{!l.value?.paused&&!l.value?.ended&&(l.value?.currentTime??0)>0||g()},E=()=>{!a.value?.paused&&!a.value?.ended&&(a.value?.currentTime??0)>0||g()},P=()=>{c("play")},k=u=>{const S=u.target;S.duration!==S.currentTime&&c("pause")},g=()=>{c("ended")};return f({play:async()=>{o.value&&o.value.play(),a.value&&a.value.play(),s.value&&s.value.play(),!o.value&&!a.value&&!s.value&&(await B((y.duration??0)*1e3),c("ended"))}}),(u,S)=>(e.openBlock(),e.createElementBlock("div",$,[t.videoWithAudioSource?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("video",{ref_key:"videoWithAudioRef",ref:o,src:t.videoWithAudioSource,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",controls:!0,playsinline:"true",onPlay:P,onPause:k,onEnded:g},null,40,C)])):t.soundEffectSource||t.videoSource?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("video",{ref_key:"videoRef",ref:a,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",src:t.soundEffectSource||t.videoSource,controls:!0,playsinline:"true",onPlay:p,onPause:i,onEnded:b},null,40,W),t.audioSource?(e.openBlock(),e.createElementBlock("audio",{key:0,ref_key:"audioSyncRef",ref:l,src:t.audioSource,controls:!0,class:"hidden",onEnded:E},null,40,M)):e.createCommentVNode("",!0)])):t.audioSource?(e.openBlock(),e.createElementBlock("div",D,[e.createElementVNode("video",{ref_key:"audioRef",ref:s,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",src:t.audioSource,poster:t.imageSource??G,controls:!0,playsinline:"true",onPlay:P,onPause:k,onEnded:g},null,40,F)])):t.imageSource?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("img",{ref_key:"imageRef",ref:v,src:t.imageSource,class:"max-w-full max-h-full object-contain"},null,8,q)])):(e.openBlock(),e.createElementBlock("div",z,e.toDisplayString(e.unref(d)("ui.common.noMedia")),1)),e.createTextVNode(" "+e.toDisplayString(t.text),1)]))}}),O=["value"],U=["value"],T=e.defineComponent({__name:"select_language",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:f}){const h=["en","ja"],d=f,y=c=>{const o=c.target;d("update:modelValue",o.value)};return(c,o)=>(e.openBlock(),e.createElementBlock("select",{value:t.modelValue,onChange:y},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(h,a=>e.createElementVNode("option",{key:a,value:a},e.toDisplayString(a),9,U)),64))],40,O))}}),H={class:"w-full overflow-hidden"},J={class:"max-w-7xl mx-auto px-4"},K={class:"flex items-center justify-between"},Q=["disabled"],X={class:"px-4"},Y=["src"],Z=["disabled"],ee=e.defineComponent({__name:"viewer",props:{dataSet:{},basePath:{},initPage:{}},emits:["updatedPage"],setup(t,{expose:f,emit:h}){const d=t,y=h,c=d.dataSet?.beats?.length??0,o=e.ref(d.initPage??0),a=e.ref(!0),l=e.ref(),s=e.ref(),v=e.ref("en"),p=e.ref("ja"),i=e.computed(()=>d.dataSet?.beats[o.value]),b=e.computed(()=>i.value?.videoWithAudioSource?d.basePath+"/"+i.value.videoWithAudioSource:""),E=e.computed(()=>i.value?.soundEffectSource?d.basePath+"/"+i.value.soundEffectSource:""),P=e.computed(()=>i.value?.videoSource?d.basePath+"/"+i.value.videoSource:""),k=e.computed(()=>{const m=i.value?.audioSources?.[p.value];return m?d.basePath+"/"+m:""}),g=e.computed(()=>i.value?.imageSource?d.basePath+"/"+i.value.imageSource:""),_=e.computed(()=>i.value?.multiLinguals?.[v.value]??i.value?.text??""),u=e.ref(!1),S=()=>{u.value=!0,s.value&&s.value.play()},ae=()=>{console.log("pause"),u.value=!1,s.value&&s.value.pause()},A=async()=>{await B(500),l.value&&l.value.play()},j=m=>{o.value!==m&&(o.value=m,u.value&&a.value&&A())},V=m=>{const n=o.value+m;return n>-1&&n<c?(j(n),y("updatedPage",n),!0):!1},ne=()=>{console.log("end"),u.value=!1,a.value&&V(1)?A():s.value&&s.value.pause()};return f({updatePage:j}),(m,n)=>(e.openBlock(),e.createElementBlock("div",H,[e.createElementVNode("div",J,[e.createElementVNode("div",K,[e.createElementVNode("button",{class:"px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",disabled:o.value===0,onClick:n[0]||(n[0]=x=>V(-1))}," Prev ",8,Q),e.createElementVNode("div",X,[e.createVNode(N,{ref_key:"mediaPlayer",ref:l,"video-with-audio-source":b.value,"video-source":P.value,"sound-effect-source":E.value,"audio-source":k.value,"image-source":g.value,index:o.value,text:_.value,duration:i.value?.duration,onPlay:S,onPause:ae,onEnded:ne},null,8,["video-with-audio-source","video-source","sound-effect-source","audio-source","image-source","index","text","duration"]),o.value+1<e.unref(c)?e.withDirectives((e.openBlock(),e.createBlock(N,{key:0,data:t.dataSet?.beats[o.value+1],"base-path":t.basePath,index:o.value+1},null,8,["data","base-path","index"])),[[e.vShow,!1]]):e.createCommentVNode("",!0)]),t.dataSet?.bgmFile?(e.openBlock(),e.createElementBlock("audio",{key:0,ref_key:"bgmRef",ref:s,src:t.dataSet?.bgmFile},null,8,Y)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",disabled:o.value>=e.unref(c)-1,onClick:n[1]||(n[1]=x=>V(1))}," Next ",8,Z)])]),e.createElementVNode("div",null,[n[4]||(n[4]=e.createTextVNode("Audio: ",-1)),e.createVNode(T,{modelValue:p.value,"onUpdate:modelValue":n[2]||(n[2]=x=>p.value=x)},null,8,["modelValue"])]),e.createElementVNode("div",null,[n[5]||(n[5]=e.createTextVNode("Text: ",-1)),e.createVNode(T,{modelValue:v.value,"onUpdate:modelValue":n[3]||(n[3]=x=>v.value=x)},null,8,["modelValue"])])]))}}),te={en:{message:{hello:"Hello"},ui:{common:{noLang:"No language available",noMedia:"No media available"},actions:{translate:"Translate",generateAudio:"Generate Audio"}},mulmoViewer:{text:"Text",audio:"Audio"},project:{productTabs:{slide:{autoPlay:"Auto Play",details:"{current} / {pages}"}}},languages:{en:"English",ja:"Japanese",zh:"Chinese",ko:"Korean",es:"Spanish",fr:"French",de:"German"}},ja:{message:{hello:"こんにちは"},ui:{common:{noLang:"言語がありません",noMedia:"メディアがありません"},actions:{translate:"翻訳",generateAudio:"音声を生成"}},mulmoViewer:{text:"テキスト",audio:"音声"},project:{productTabs:{slide:{autoPlay:"自動再生",details:"{current} / {pages}"}}},languages:{en:"英語",ja:"日本語",zh:"中国語",ko:"韓国語",es:"スペイン語",fr:"フランス語",de:"ドイツ語"}}},oe=w.createI18n({legacy:!1,locale:"en",fallbackLocale:"en",messages:te});r.MulmoView=ee,r.i18n=oe,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.MulmoCastViewer={},m.Vue))})(this,(function(m,e){"use strict";const _=async a=>await new Promise(h=>setTimeout(h,a)),N={class:"items-center justify-center w-full"},L={key:0},$=["src"],R={key:1,class:"relative inline-block"},C=["src"],T=["src"],A={key:2},j=["src","poster"],W={key:3,class:"relative inline-block"},D=["src"],M={key:4},F="https://github.com/receptron/mulmocast-cli/blob/main/assets/images/mulmocast_credit.png?raw=true",x=e.defineComponent({__name:"mulmo_player",props:{index:{},videoWithAudioSource:{},soundEffectSource:{},videoSource:{},imageSource:{},audioSource:{},text:{},duration:{}},emits:["play","pause","ended"],setup(a,{expose:h,emit:S}){const l=a,d=S,i=e.ref(),o=e.ref(),n=e.ref(),f=e.ref(),r=e.ref(),y=()=>{n.value&&o.value&&(n.value.currentTime=o.value.currentTime,n.value.currentTime===o.value.currentTime&&n.value.play()),d("play")},P=u=>{!o.value?.ended&&n?.value&&n.value?.pause(),console.log(u),k(u)},E=()=>{!n.value?.paused&&!n.value?.ended&&(n.value?.currentTime??0)>0||v()},s=()=>{!o.value?.paused&&!o.value?.ended&&(o.value?.currentTime??0)>0||v()},g=()=>{d("play")},k=u=>{const p=u.target;p.duration!==p.currentTime&&d("pause")},v=()=>{d("ended")};return h({play:async()=>{i.value&&i.value.play(),o.value&&o.value.play(),f.value&&f.value.play(),!i.value&&!o.value&&!f.value&&(await _((l.duration??0)*1e3),d("ended"))}}),(u,p)=>(e.openBlock(),e.createElementBlock("div",N,[a.videoWithAudioSource?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("video",{ref_key:"videoWithAudioRef",ref:i,src:a.videoWithAudioSource,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",controls:!0,playsinline:"true",onPlay:g,onPause:k,onEnded:v},null,40,$)])):a.soundEffectSource||a.videoSource?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("video",{ref_key:"videoRef",ref:o,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",src:a.soundEffectSource||a.videoSource,controls:!0,playsinline:"true",onPlay:y,onPause:P,onEnded:E},null,40,C),a.audioSource?(e.openBlock(),e.createElementBlock("audio",{key:0,ref_key:"audioSyncRef",ref:n,src:a.audioSource,controls:!0,class:"hidden",onEnded:s},null,40,T)):e.createCommentVNode("",!0)])):a.audioSource?(e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("video",{ref_key:"audioRef",ref:f,class:"mulmocast-video mx-auto h-auto max-h-[80vh] w-auto object-contain",src:a.audioSource,poster:a.imageSource??F,controls:!0,playsinline:"true",onPlay:g,onPause:k,onEnded:v},null,40,j)])):a.imageSource?(e.openBlock(),e.createElementBlock("div",W,[e.createElementVNode("img",{ref_key:"imageRef",ref:r,src:a.imageSource,class:"max-w-full max-h-full object-contain"},null,8,D)])):(e.openBlock(),e.createElementBlock("div",M,"No media available")),e.createTextVNode(" "+e.toDisplayString(a.text),1)]))}}),z=["value"],O=["value"],V=e.defineComponent({__name:"select_language",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:h}){const S=["en","ja"],l=h,d=i=>{const o=i.target;l("update:modelValue",o.value)};return(i,o)=>(e.openBlock(),e.createElementBlock("select",{value:a.modelValue,onChange:d},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(S,n=>e.createElementVNode("option",{key:n,value:n},e.toDisplayString(n),9,O)),64))],40,z))}}),q={class:"w-full overflow-hidden"},I={class:"max-w-7xl mx-auto px-4"},G={class:"flex items-center justify-between"},H=["disabled"],J={class:"px-4"},K=["disabled"],Q=["src"],U=e.defineComponent({__name:"mulmo_viewer",props:{dataSet:{},basePath:{},initPage:{},audioLang:{default:"en"},textLang:{default:"en"}},emits:["updatedPage","update:audioLang","update:textLang"],setup(a,{expose:h,emit:S}){const l=a,d=S,i=l.dataSet?.beats?.length??0,o=e.ref(l.initPage??0),n=e.ref(!0),f=e.ref(),r=e.ref(),y=e.computed({get:()=>l.audioLang,set:t=>d("update:audioLang",t||"en")}),P=e.computed({get:()=>l.textLang,set:t=>d("update:textLang",t||"en")}),E=e.computed(()=>l.dataSet?.beats[o.value]),s=t=>t?l.basePath+"/"+t:"",g=e.ref(!1),k=()=>{g.value=!0,r.value&&r.value.play()},v=()=>{console.log("pause"),g.value=!1,r.value&&r.value.pause()},b=async()=>{await _(500),f.value&&f.value.play()},u=t=>{o.value!==t&&(o.value=t,g.value&&n.value&&b())},p=t=>{const c=o.value+t;return c>-1&&c<i?(u(c),d("updatedPage",c),!0):!1},X=()=>{console.log("end"),g.value=!1,n.value&&p(1)?b():r.value&&r.value.pause()},B=e.computed(()=>{const t=E.value,c=t?.audioSources?.[y.value];return{videoWithAudioSource:s(t?.videoWithAudioSource),videoSource:s(t?.videoSource),soundEffectSource:s(t?.soundEffectSource),audioSource:c?l.basePath+"/"+c:"",imageSource:s(t?.imageSource),index:o.value,text:t?.multiLinguals?.[P.value]??t?.text??"",duration:t?.duration,onPlay:k,onPause:v,onEnded:X}}),Y=e.computed(()=>l.dataSet?.beats[o.value+1]),w=e.computed(()=>{if(o.value+1>=i)return null;const t=Y.value;return{videoWithAudioSource:s(t?.videoWithAudioSource),videoSource:s(t?.videoSource),soundEffectSource:s(t?.soundEffectSource),audioSource:t?.audioSources?.[y.value]?l.basePath+"/"+t.audioSources[y.value]:"",imageSource:s(t?.imageSource),index:o.value+1,text:t?.multiLinguals?.[P.value]??t?.text??"",duration:t?.duration}}),Z=e.computed(()=>({MulmoPlayer:x,pageProps:B.value,currentPage:o.value,pageCount:i,pageMove:p,isPlaying:g.value,audioLang:y,textLang:P,SelectLanguage:V}));return h({updatePage:u}),(t,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(Z.value)),()=>[e.createElementVNode("div",q,[e.createElementVNode("div",I,[e.createElementVNode("div",G,[e.createElementVNode("button",{class:"px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",disabled:o.value===0,onClick:c[0]||(c[0]=ee=>p(-1))}," Prev ",8,H),e.createElementVNode("div",J,[e.createVNode(x,e.mergeProps({ref_key:"mediaPlayer",ref:f},B.value),null,16)]),e.createElementVNode("button",{class:"px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600 disabled:opacity-50",disabled:o.value>=e.unref(i)-1,onClick:c[1]||(c[1]=ee=>p(1))}," Next ",8,K)])])])]),w.value?e.withDirectives((e.openBlock(),e.createBlock(x,e.normalizeProps(e.mergeProps({key:0},w.value)),null,16)),[[e.vShow,!1]]):e.createCommentVNode("",!0),a.dataSet?.bgmFile?(e.openBlock(),e.createElementBlock("audio",{key:1,ref_key:"bgmRef",ref:r,src:a.dataSet?.bgmFile},null,8,Q)):e.createCommentVNode("",!0)],64))}});m.MulmoViewer=U,m.SelectLanguage=V,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast-viewer",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "dist/mulmocast-viewer.umd.js",
@@ -18,8 +18,7 @@
18
18
  "dist/mulmocast-viewer.umd.js",
19
19
  "dist/mulmocast-viewer.es.js",
20
20
  "dist/mulmocast-viewer.css",
21
- "dist/index.d.ts",
22
- "dist/i18n.d.ts"
21
+ "dist/index.d.ts"
23
22
  ],
24
23
  "scripts": {
25
24
  "fileList": "npx tsx batch/file_list.ts",
@@ -33,7 +32,6 @@
33
32
  "format:check": "prettier --check \"src/**/*.{ts,vue,css,html,json}\""
34
33
  },
35
34
  "dependencies": {
36
- "pinia": "^3.0.3",
37
35
  "vue": "^3.5.22",
38
36
  "vue-i18n": "^11.1.12",
39
37
  "vue-router": "^4.6.3"
package/dist/i18n.d.ts DELETED
@@ -1,76 +0,0 @@
1
- import { I18n } from 'vue-i18n';
2
- declare const i18n: I18n<{
3
- en: {
4
- message: {
5
- hello: string;
6
- };
7
- ui: {
8
- common: {
9
- noLang: string;
10
- noMedia: string;
11
- };
12
- actions: {
13
- translate: string;
14
- generateAudio: string;
15
- };
16
- };
17
- mulmoViewer: {
18
- text: string;
19
- audio: string;
20
- };
21
- project: {
22
- productTabs: {
23
- slide: {
24
- autoPlay: string;
25
- details: string;
26
- };
27
- };
28
- };
29
- languages: {
30
- en: string;
31
- ja: string;
32
- zh: string;
33
- ko: string;
34
- es: string;
35
- fr: string;
36
- de: string;
37
- };
38
- };
39
- ja: {
40
- message: {
41
- hello: string;
42
- };
43
- ui: {
44
- common: {
45
- noLang: string;
46
- noMedia: string;
47
- };
48
- actions: {
49
- translate: string;
50
- generateAudio: string;
51
- };
52
- };
53
- mulmoViewer: {
54
- text: string;
55
- audio: string;
56
- };
57
- project: {
58
- productTabs: {
59
- slide: {
60
- autoPlay: string;
61
- details: string;
62
- };
63
- };
64
- };
65
- languages: {
66
- en: string;
67
- ja: string;
68
- zh: string;
69
- ko: string;
70
- es: string;
71
- fr: string;
72
- de: string;
73
- };
74
- };
75
- }, {}, {}, string, false>;
76
- export default i18n;