Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Fixed audio issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Void-Cat committed Jan 18, 2019
1 parent 13b2579 commit f246e95
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const createWindow = () => {
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
protocol.registerFileProtocol('local', (request,callback) => {
const url = request.url.substr(8)
const url = request.url.substr(9)
callback({path: path.normalize(url)})
}, (error) => {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/ts/tease/imagecontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export default class ImageController {

for (let i = start; i < this.images.length; i++) {
let path = this.images[i].replace(/\\/gi, '/')
if (path.indexOf("local://") !== 0)
path = "local://" + path
if (path.indexOf("local:///") !== 0)
path = "local:///" + path
this.images[i] = path
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/ts/tease/strokingcontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare const storage
import ViewController from './viewcontroller'
import * as fs from 'fs'
import {isNumber, isBoolean, isNull, isNullOrUndefined} from 'util'
import * as path from 'path'

export default class StrokingController {
carousel: HTMLAudioElement[] = []
Expand All @@ -22,18 +23,18 @@ export default class StrokingController {
let audiosrc
switch (storage.get('tease.setup.tickersound')) {
case 'metronome':
audiosrc = `${__dirname}/../../audio/metronome.ogg`
audiosrc = `local:///${__dirname}/../../audio/metronome.ogg`
break

case 'custom':
audiosrc = storage.get("tease.setup.customticker")
audiosrc = `local:///${storage.get("tease.setup.customticker")}`
break

case 'default':
default:
audiosrc = `${__dirname}/../../audio/ticker.ogg`
audiosrc = `local:///${__dirname}/../../audio/ticker.ogg`
}
if (!fs.existsSync(audiosrc))
if (!fs.existsSync(audiosrc.substring(9)))
throw new Error(`Ticker at source '${audiosrc}' could not be found.`)
for (let i = 0; i < 6; i++) {
this.carousel.push(new Audio())
Expand Down
5 changes: 3 additions & 2 deletions src/ts/tease/viewcontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ExitController from './exitcontroller'
import ImageController from './imagecontroller'
import StrokingController from './strokingcontroller'
import TeaseEvent from './teaseEvent'
import * as path from 'path'

export default class ViewController {
buffer: HTMLImageElement
Expand Down Expand Up @@ -33,10 +34,10 @@ export default class ViewController {
this.viewID = 'img' + viewID

if (storage.get('tease.setup.announcecard')) {
this.announcer.card.src = `${__dirname}/../../audio/card.ogg`
this.announcer.card.src = `local:///${__dirname}/../../audio/card.ogg`
}
if (storage.get('tease.setup.announceimage')) {
this.announcer.image.src = `${__dirname}/../../audio/slidechange.ogg`
this.announcer.image.src = `local:///${__dirname}/../../audio/slidechange.ogg`
}
this.snackbarElement.closeOnEscape = false
}
Expand Down

0 comments on commit f246e95

Please sign in to comment.