Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hanuman Midgard to Asgard #53

Closed
wants to merge 166 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
fe58e27
Add route to show specific <chap, verse>
rtshkmr Dec 5, 2023
714834b
Add JS-hook for WebShare-API/clipboard-copy
rtshkmr Dec 6, 2023
3ea3a4f
Cleanups based on PR review suggestions
rtshkmr Dec 19, 2023
f5b2b05
Use external heex template for show_verse
rtshkmr Dec 19, 2023
ee769e9
Support the addition of meta tags in the html head
rtshkmr Dec 20, 2023
fbc0162
Add meta tags to other views in gita_live
rtshkmr Dec 20, 2023
6dfa835
Add image generation & routing
rtshkmr Dec 24, 2023
3a6e44b
Attempt minor fixes
rtshkmr Dec 24, 2023
d25475f
Navigate from chapter to individual verse
rtshkmr Dec 29, 2023
69da68f
Improve clipboard content
rtshkmr Dec 29, 2023
ea810ef
Add just-in-time image creation for og-images
rtshkmr Dec 30, 2023
733852c
enable 404 templates
Dec 30, 2023
49487aa
Consolidate Fallback Controller
Dec 30, 2023
8594bf3
Fix text
rtshkmr Dec 30, 2023
3239319
Add OgAdapter with filename encoder-decoder pair
rtshkmr Dec 31, 2023
6dbc7fb
Temporarily use atoms as text-id
rtshkmr Dec 31, 2023
6404adc
[sync] prod to quotation-enginge-v0 (#14)
rtshkmr Jan 2, 2024
38352c3
Hide issue template's helping words in dropdown.
rtshkmr Jan 2, 2024
05317c2
[WIP] Attempt @ YT Iframe Embed
rtshkmr Jan 3, 2024
cd8b297
Successfully use iframe embed
rtshkmr Jan 4, 2024
6b22a5c
Add v0 of quotation engine (#9)
rtshkmr Jan 6, 2024
64b1f24
Merge branch 'master' into ritesh/operation/#10-youtube-player
rtshkmr Jan 6, 2024
565a8ad
Add reference to obj via window.youtubePlayer
rtshkmr Jan 6, 2024
9315974
Add examples of interfacing w playr's playback fns
rtshkmr Jan 7, 2024
91e7c75
Add examples of playr's videoStats APIs
rtshkmr Jan 7, 2024
1b8f095
Add demonstration of using Floating UI (#20)
rtshkmr Jan 11, 2024
9bacc24
Merge branch 'master' into ritesh/operation/#10-youtube-player
rtshkmr Jan 12, 2024
726d114
Add basic version of a mini-player
rtshkmr Jan 13, 2024
1ea9f5a
Make improvements from code review
rtshkmr Jan 14, 2024
cc9ef5d
Cleanup code
rtshkmr Jan 14, 2024
fc13ae2
YouTube: User player API to control player & get stats (#15)
rtshkmr Jan 15, 2024
68e28e6
Add script for .srt creation
rtshkmr Jan 16, 2024
1595af5
Merge branch 'master' into ritesh/operation/video-IR
rtshkmr Jan 16, 2024
88c5f80
Scraper Lite
Jan 16, 2024
b7e3e07
[Attempt]: attempt usage of libindic for sim score
rtshkmr Jan 17, 2024
13571d7
[ATTEMPT]: minor improvements
rtshkmr Jan 18, 2024
ba60721
Add input file
rtshkmr Jan 18, 2024
35e7c92
[ATTEMPT] Add example of supposed usage of inltk
rtshkmr Jan 18, 2024
9d53d5e
Map structured text to lowfi autogenerated caption
rtshkmr Jan 21, 2024
86ccc12
Minor cleanups
rtshkmr Jan 21, 2024
1a50e69
[ATTEMPT]: migration for cloning the gita
rtshkmr Jan 22, 2024
472ee73
[WIP] Migration file & livebook for cloning gita
rtshkmr Jan 27, 2024
a0b2266
Changing Ports Config
Jan 27, 2024
5769050
General Changes to Migrations
Jan 27, 2024
38b7d6e
[ATTEMPT]: changeset issues
rtshkmr Jan 27, 2024
1ad4931
Vyasa Struct Formation - Chapter Verse Axis
Jan 27, 2024
84c375e
Clean up working example of how to do changesets
rtshkmr Jan 27, 2024
3c8fa9e
Fix bug in data ingestion script
rtshkmr Jan 28, 2024
20b7205
Clone db
rtshkmr Jan 28, 2024
638664b
Wired in enough to merge changes in; still unclean
rtshkmr Jan 28, 2024
cc5d2d9
Add missed fields to Chapter schema
rtshkmr Jan 28, 2024
3df8efd
Minor aesthetic changes
rtshkmr Jan 28, 2024
d822440
Use friendly source_title instead of source_id
rtshkmr Jan 28, 2024
7c54867
Cleanups
rtshkmr Jan 28, 2024
677dd41
Polymorphic Translations
Jan 29, 2024
dbd2c14
untested attempt at updating the db.seed()
rtshkmr Jan 31, 2024
c716a36
Use polymorphic entities in liveview
rtshkmr Feb 1, 2024
aefdfea
Minor cleanups
rtshkmr Feb 1, 2024
a552885
Make minor improvements from code review
rtshkmr Feb 3, 2024
cf221ea
Kill transliteration
rtshkmr Feb 3, 2024
c79183d
Use Query,separate fn for pressie ctx,inject lang
rtshkmr Feb 3, 2024
4d826a2
[Operation] Video IR (#22)
rtshkmr Feb 4, 2024
34b43c1
Merge pull request #27 from ve1ld/ritesh/gita-to-db
ks0m1c Feb 4, 2024
d2f0936
Migrations Ground Prep
Feb 6, 2024
2919ab3
Schema and Query Contexts
Feb 6, 2024
22c95d1
Local Infra Integration for MinIO
Feb 6, 2024
5afadec
ext_path support for upload
Feb 6, 2024
325a2e7
Tracks & Events
Feb 6, 2024
62e0e0f
Minor change: ~R -> ~r
rtshkmr Feb 7, 2024
a95ecca
Init audio player css
rtshkmr Feb 8, 2024
7bc8b37
[Attempt]: add a stub getter for voices
rtshkmr Feb 9, 2024
7ab35aa
fs writer using run()
Feb 9, 2024
901b797
Merge branch 'ops/ValmikiRamayana' into ops/media-player
rtshkmr Feb 9, 2024
fc87f1e
Add Written.get_voice_stub()
rtshkmr Feb 10, 2024
94115fe
Handle play and pause, less elapsed-time tracking
rtshkmr Feb 11, 2024
4bed76c
Keep playback state
rtshkmr Feb 12, 2024
7809cfb
Handle (resume / fresh) play cases
rtshkmr Feb 13, 2024
df3ea6c
Foundations of the CLI (#24)
ks0m1c Feb 13, 2024
cc010de
Gita/1 with Event Fragments Support
Feb 14, 2024
8a2d0c4
Update Stub fns
Feb 14, 2024
1f1786a
Minor improvements to seeder file and other assocs
rtshkmr Feb 17, 2024
f0a6f88
[Attempt]: Face race condition, happy path works
rtshkmr Feb 17, 2024
be68f42
It's aliveeeeeeeee
rtshkmr Feb 17, 2024
dee98f5
Session Data Client/Server Sync
Feb 19, 2024
1e2ebee
PubSub with Handshake
Feb 19, 2024
040e874
Client Side Events Handle
Feb 19, 2024
e260100
Sync Session with 3-way handshake
Feb 19, 2024
d73e3af
Shift gen_voice_playback to media_library
rtshkmr Feb 19, 2024
273e15f
Support player seeking
rtshkmr Feb 20, 2024
d7de86c
Add missing files
rtshkmr Feb 21, 2024
12fa218
Admin Controls for Event
Feb 21, 2024
aac5821
Update AdminView
Feb 22, 2024
3c3381d
Merge branch 'master' into ops/media-player
rtshkmr Feb 22, 2024
d8bd6f8
Cleanups from code review
rtshkmr Feb 23, 2024
fa98213
Make improvements to player related code
rtshkmr Feb 23, 2024
393abcb
Deprecate gita and text routes, assoc source code
rtshkmr Feb 23, 2024
5e26907
Change voice.prop -> voice.meta
rtshkmr Feb 23, 2024
f85e65a
Merge pull request #41 from ve1ld/ops/media-player
ks0m1c Feb 23, 2024
de8c3e4
Trigger diff
rtshkmr Feb 24, 2024
ab140dd
Merge branch 'master' into ops/AdminControls
ks0m1c Feb 24, 2024
aecfad8
Intro Translations to Gita
Feb 24, 2024
77b4896
syncProgressTimer() after seekTo event
rtshkmr Feb 24, 2024
5faa397
Patching up Gita Source Material
Feb 24, 2024
271118d
audio next case fixed
Feb 25, 2024
dd594fa
Merge pull request #44 from ve1ld/ops/AdminControls
ks0m1c Feb 25, 2024
3d2a235
Add v0 seeder fn for Hanuman Chalisa
rtshkmr Feb 25, 2024
f1d83d4
[Attempt] Add chapter for hanuman_chalisa
rtshkmr Feb 25, 2024
4c0329d
[Attempt] Multiple query changes
rtshkmr Feb 25, 2024
399d8c0
Sorted Verses
Feb 25, 2024
5f27ca7
Fix wrong assocs when creating verse-translations
rtshkmr Feb 25, 2024
0c380d9
S3 Object Storage Service Groundworks
Feb 25, 2024
1e0afac
Merge branch 'prod' into feature/hanuman
ks0m1c Feb 25, 2024
b008965
Complete seeder for Chalisa events
rtshkmr Feb 25, 2024
aeb7b8f
Merge branch 'feature/hanuman' into chore/add-hanuman-chalisa-seeder
rtshkmr Feb 25, 2024
3324248
Deprecate Text Live
Feb 25, 2024
2594481
Support playback seeking by clicking on the verse
rtshkmr Feb 26, 2024
99cd949
Init media bridge
rtshkmr Feb 28, 2024
be6e8de
[Attempt] parent-child comms
rtshkmr Feb 28, 2024
7953c03
Its the phx-update=ignore clause
Feb 28, 2024
ad73483
Decouple mediabridge (abs media play) & aud player
rtshkmr Feb 28, 2024
875d91a
Some syntax fixes
Feb 29, 2024
ae70f73
Use the correct hook, handle event emits properly
rtshkmr Feb 29, 2024
f9dcb60
Include video & assoc w voice in existing seeders
rtshkmr Mar 2, 2024
aefee6d
Pass video_id prop as part of the :voice_ack
rtshkmr Mar 2, 2024
2ad6ea0
Define video player config from media_bridge
rtshkmr Mar 2, 2024
458d375
Sync audio and video, with issues
rtshkmr Mar 2, 2024
6380915
Merge pull request #47 from ve1ld/chore/player-improvements
ks0m1c Mar 3, 2024
c3764e3
Support video-hiding via toggle icon
rtshkmr Mar 3, 2024
cfd6ae0
Use css utility & improve perf from css changes
rtshkmr Mar 3, 2024
e292bcf
CSS: use fixed inset to make media_bridge stick
rtshkmr Mar 3, 2024
fa8aec1
Add toggle b/w follow mode and non-follow-mode
rtshkmr Mar 3, 2024
d518e6d
Floater: init generic floater hook
rtshkmr Mar 3, 2024
91ee569
Set up potential style system
rtshkmr Mar 4, 2024
5515cb1
General-UI improvements
rtshkmr Mar 4, 2024
188685f
Add scroll padding, other UI udpates
rtshkmr Mar 4, 2024
e1cee03
Minor UI Padding
Mar 4, 2024
c53bfbc
Event Bus
Mar 5, 2024
e8e368c
Classic MIssing bridge
Mar 5, 2024
43a04cf
[WIP] Use seekTimeBridge for progress-bar seeking
rtshkmr Mar 6, 2024
07e527f
Use seekToEvent bridge for YouTubePlayer hook
rtshkmr Mar 6, 2024
1c4aa3f
Complete handling of the seekTime event bridge
rtshkmr Mar 7, 2024
26542b0
Make progress_bar sub to seekTime
rtshkmr Mar 7, 2024
6cf307d
Use PlayPauseBridge
rtshkmr Mar 7, 2024
67d30c6
Minor cleanups
rtshkmr Mar 7, 2024
9b62961
Minor changes
rtshkmr Mar 7, 2024
8b8ce7e
Let the heart beat
rtshkmr Mar 7, 2024
4a5bb85
Massive cleanups, let follow mode work magically
rtshkmr Mar 7, 2024
33d1769
More cleanups
rtshkmr Mar 7, 2024
59cb3b1
bless me
rtshkmr Mar 7, 2024
4b74180
bless me
rtshkmr Mar 7, 2024
3993d3b
bless u
Mar 7, 2024
c611eac
Clean up Seeder Branch
Mar 8, 2024
b4b59cd
Merge pull request #45 from ve1ld/chore/add-hanuman-chalisa-seeder
ks0m1c Mar 8, 2024
cbedcbd
Merge pull request #49 from ve1ld/feature/video-sync
ks0m1c Mar 8, 2024
cc49283
Merge pull request #50 from ve1ld/patch/video-sync/progressbar
ks0m1c Mar 8, 2024
b1713f4
Merge branch 'feature/hanuman' into feature/media-bridge
ks0m1c Mar 8, 2024
9b3aa4c
[WIP] Add fallback component for floater to attach
rtshkmr Mar 8, 2024
e5821a9
Floating video player handling (incl. mobile view)
rtshkmr Mar 8, 2024
9b920d7
Minor text size updates
rtshkmr Mar 8, 2024
42d4326
Gimped assign-metas
rtshkmr Mar 8, 2024
c975982
Data Dump and Restore
Mar 8, 2024
fb2a21e
Merge pull request #54 from ve1ld/chore/UI-polishing-prior-to-soft-la…
ks0m1c Mar 8, 2024
7061ccc
Keyboard Bookmarklet
Mar 10, 2024
9a59bbd
Duration (-)
Mar 11, 2024
a14a4bd
EventZips et al
Mar 11, 2024
4eb8e6c
Merge pull request #58 from ve1ld/ops/KeyboardWarrior
ks0m1c Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

AWS_ACCESS_KEY_ID=secrettunnel
AWS_SECRET_ACCESS_KEY=secrettunnel
AWS_DEFAULT_REGION=ap-southeast-1
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/alchemy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ assignees: ''

### Present Context

<details>
<summary>Helping words...</summary>

Where we collectively investigate and interrogate the problem space and iteratively scope our approach.

Breakdown to landmarks that communicate shared context we are working towards through 2-tiered task list, CRUD list elements as development unfolds.
Expand All @@ -25,8 +28,16 @@ Strike the scope of code that reveals the most about the problem/solution FIRST

```
---

</details>

### Groundwork

<details>
<summary> Helping words...</summary>



Introduce us to the problem space. Write out what you already know about the terrain you are the recce commander enriching us with details beyond the fog of war.

Where have you tried applying and encountered difficulties?
Expand All @@ -42,8 +53,15 @@ Emphasis on previous or current practice to discover what is ugly, missing, or u
INPUT UR ANSWER HERE
```
---


</details>


### Reflection

<details>
<summary> Helping words...</summary>
Where the eternal wheel returns back to practice and what we finally implemented is to be outlined. You are the historian or archivist bringing clarity to future-yous and us about your foray.

Emphasis on approaching timeless solutions for well-defined problem space through distillation by decanting that which is un-needed and abstracting that which is essential to approaching the problem space.
Expand All @@ -54,4 +72,7 @@ Add any reflections and internal links to future potential and blindsides.
INPUT UR ANSWER HERE
```

</details>



1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ npm-debug.log

# Any Secret Configs
/config/*.secret.exs
/venv/
10 changes: 9 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ Wherever there be anything you dost not comprehend, cease to continue writing
-- Vyasa, Adi Parva - Mahabharatam
#+END_QUOTE

### CLI Helpsheet

```elixir
# build script
mix escript.build
# fetch from domain/path --storage :mode
./vyasa fetch shlokam.org/hanumanchalisa --storage file
```
* Forms of Prior Art
** [[http://worrydream.com/refs/Nelson-ComputerLibDreamMachines1975.pdf#page=57][Xanadu Pattern]]
** [[http://worrydream.com/refs/Nelson-ComputerLibDreamMachines1975.pdf#page=57][Xanadu Pattern ]]

Ted Nelson the granddaddy of hypertext media, need I say more. The introduction to [[https://cs.brown.edu/people/nmeyrowi/LiteraryMachinesChapter2.pdf#page=12][Literary Machines]] is instructive to delineating the problem boundaries for literature

Expand Down
54 changes: 54 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@
@import "tailwindcss/components";
@import "tailwindcss/utilities";

/**
* Root definitions that serve as overridable css variables
*
--chili-red: #E83A21ff;
--pearl: #E3DABEff;
--black: #070302ff;
--dun: #D4CAABff;
--blood-red: #5B1208ff;
**/
@layer base {
:root {
--chili-red: #E83A21ff;
--pearl: #E3DABEff;
--black: #070302ff;
--dun: #D4CAABff;
--blood-red: #5B1208ff;

--white-alabaster: #F3EFE3;
--linen: #FAF1E6;

--aerospace-orange: #FD4F00;
--coral-orange: #FF8349;
--atomic-tangerine: #FF9B6D;


--brown: #922E00;
--sienna: #7F2800;
--rust: #AE3700;

--color-brand: var(--aerospace-orange);
--color-brand-light: var(--atomic-tangerine);
--color-brand-extra-light: var(--linen);
--color-brand-accent: var(--aerospace-orange);
--color-brand-accent-light: var(--atomic-tangerine);

--color-brand-dark: var(--brown);
--color-brand-extra-dark: var(--sienna);


--color-primary: var(--chili-red);
--color-primary-accent: var(--chili-red);
--color-primary-background: var(--white-alabaster);
--color-secondary: var(--blood-red);
--color-secondary-background: var(--dun);
--color-text: var(--black)
}
}

/* fonts declared from priv/assets/fonts */

@font-face {
Expand All @@ -10,4 +58,10 @@
url('/fonts/gotu/Gotu-Regular.woff') format('woff'),
url('/fonts/gotu/Gotu-Regular.ttf') format('ttf');
}


/* This file is for your main application CSS */

.emphasized-verse {
@apply bg-brandAccentLight border-b-0 border-l-8 border-black p-4 pl-8 rounded-sm;
}
34 changes: 22 additions & 12 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,36 @@
//

// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
import "phoenix_html";
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
import topbar from "../vendor/topbar"
import { Socket } from "phoenix";
import { LiveSocket } from "phoenix_live_view";
import topbar from "../vendor/topbar";
import Hooks from "./hooks";

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute(
"content",
);
let liveSocket = new LiveSocket("/live", Socket, {
params: { _csrf_token: csrfToken,
locale: Intl.NumberFormat().resolvedOptions().locale,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
timezone_offset: -new Date().getTimezoneOffset(),
session: JSON.parse(localStorage.getItem("session")) || {active: true}
},
hooks: Hooks,
});

// Show progress bar on live navigation and form submits
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
window.addEventListener("phx:page-loading-start", (_info) => topbar.show(300));
window.addEventListener("phx:page-loading-stop", (_info) => topbar.hide());

// connect if there are any LiveViews on the page
liveSocket.connect()
liveSocket.connect();

// expose liveSocket on window for web console debug logs and latency simulation:
// >> liveSocket.enableDebug()
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
// >> liveSocket.disableLatencySim()
window.liveSocket = liveSocket

window.liveSocket = liveSocket;
171 changes: 171 additions & 0 deletions assets/js/hooks/audio_player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* Hooks for audio player.
* Leader
* This hook shall interact with the html5 player via it's known apis, on things like:
* 1. playback info relevant to the audio player
*
*
* Additionally, it shall emit events back to it's corresponding parent hook (MediaPlayer)
* so that the media player can effect changes to visual info like player timestamps, durations and such.
*
* In this way, "Playback" state is managed by MediaBridge, and is displayed by the Media Library hook to follow a
* general player-agnostic fashion. "Playback" and actual playback (i.e. audio or video playback) is decoupled, allowing
* us the ability to reconcile bufferring states and other edge cases, mediated by the Media Bridge.
* */
let rand = (min, max) => Math.floor(Math.random() * (max - min) + min)
let isVisible = (el) => !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length > 0)

let execJS = (selector, attr) => {
document.querySelectorAll(selector).forEach(el => liveSocket.execJS(el, el.getAttribute(attr)))
}

import {seekTimeBridge, playPauseBridge, heartbeatBridge} from "./media_bridge.js"
import {formatDisplayTime, nowSeconds} from "../utils/time_utils.js"

AudioPlayer = {
mounted() {
this.isFollowMode = false;
this.playbackBeganAt = null
this.player = this.el.querySelector("audio")

document.addEventListener("click", () => this.enableAudio())

this.player.addEventListener("loadedmetadata", e => this.handleMetadataLoad(e))

this.handleEvent("initSession", (sess) => this.initSession(sess))

/// Audio playback events:
this.handleEvent("stop", () => this.stop())

/// maps eventName to its deregisterer:
this.eventBridgeDeregisterers = {
seekTime: seekTimeBridge.sub(payload => this.handleExternalSeekTime(payload)),
playPause: playPauseBridge.sub(payload => this.handleMediaPlayPause(payload)),
heartbeat: heartbeatBridge.sub(payload => this.echoHeartbeat(payload)),
}
},
/// Handlers:
handleMediaPlayPause(payload) {
console.log("[playPauseBridge::audio_player::playpause] payload:", payload)
const {
cmd,
player_details: playerDetails,
} = payload

if (cmd === "play") {
this.playMedia(playerDetails)
}
if (cmd === "pause") {
this.pause()
}
},
handleExternalSeekTime(payload) {
console.log("[audio_player::seekTimeBridgeSub::seekTimeHandler] this:", this);
const {seekToMs: timeMs} = payload;
const timeS = Math.round(timeMs/1000);
this.seekToS(timeS)
},
echoHeartbeat(heartbeatPayload) {
const shouldIgnoreSignal = heartbeatPayload.originator === "AudioPlayer";
if(shouldIgnoreSignal) {
return
}

console.log("[heartbeatBridge::audio_player] payload:", heartbeatPayload)
const echoPayload = {
originator: "AudioPlayer",
currentPlaybackInfo: {
isPlaying: !this.player.paused,
currentTime: this.player.currentTime,
duration: this.player.duration,
}
}
heartbeatBridge.pub(echoPayload)
},
initSession(sess) {
localStorage.setItem("session", JSON.stringify(sess))
},
handleMetadataLoad(e) {
console.log("Loaded metadata!", {
duration: this.player.duration,
event: e,
})
},
handlePlayPause() {
console.log("{play_pause event triggerred} player:", this.player)
if(this.player.paused){
this.play()
}
},
/**
* This "init" behaviour has been mimicked from live_beats.
* It is likely there to enable the audio player bufferring.
* */
enableAudio() {
if(this.player.src){
document.removeEventListener("click", this.enableAudio)
const hasNothingToPlay = this.player.readyState === 0;
if(hasNothingToPlay){
this.player.play().catch(error => null)
this.player.pause()
}
}
},
playMedia(params) {
console.log("PlayMedia", params)
const {filePath, isPlaying, elapsed, artist, title} = params;

const beginTime = nowSeconds() - elapsed
this.playbackBeganAt = beginTime
let currentSrc = this.player.src.split("?")[0]

const isLoadedAndPaused = currentSrc === filePath && !isPlaying && this.player.paused;
if(isLoadedAndPaused){
this.play({sync: true})
} else if(currentSrc !== filePath) {
currentSrc = filePath
this.player.src = currentSrc
this.play({sync: true})
}

const isMediaSessionApiSupported = "mediaSession" in navigator;
if(isMediaSessionApiSupported){
navigator.mediaSession.metadata = new MediaMetadata({artist, title})
}
},
play(opts = {}){
console.log("Triggered playback, check params", {
player: this.player,
opts,
})

let {sync} = opts

this.player.play().then(() => {
if(sync) {
const currentTime = nowSeconds() - this.playbackBeganAt
this.player.currentTime = currentTime;
const formattedCurrentTime = formatDisplayTime(currentTime);
}
}, error => {
if(error.name === "NotAllowedError"){
execJS("#enable-audio", "data-js-show")
}
})
},
pause(){
this.player.pause()
},
stop(){
this.player.pause()
this.player.currentTime = 0
},
seekToS(time) {
const beginTime = nowSeconds() - time
this.playbackBeganAt = beginTime;
this.player.currentTime = time;
},
}


export default AudioPlayer;
Loading
Loading