orhun / CoolModFiles

A web player that plays some cool MOD files randomly 🎶
https://CoolModFiles.com
GNU General Public License v3.0
136 stars 12 forks source link

Page loads in Safari but Music doesn't play #4

Open sanindya-iiitd opened 3 years ago

sanindya-iiitd commented 3 years ago

Screenshot 2020-10-20 at 7 14 03 PM

I tried:

Safari: Version 14.0 (15610.1.28.1.9, 15610)

bufgix commented 3 years ago

Unfortunately player implementation does not support Safari browser. Use Firefox or Chrome instead

orhun commented 3 years ago

I agree with @bufgix. Have you tried to play a mod on modarchive.org?

sanindya-iiitd commented 3 years ago

I see. No, the online player on modarchive.org doesn't work in Safari either. Any idea if this could be due to https://github.com/OpenMPT/openmpt or https://github.com/deskjet/chiptune2.js?

I tried this demo in Safari and it works: https://deskjet.github.io/chiptune2.js/#

orhun commented 3 years ago

No, the online player on modarchive.org doesn't work in Safari either.

That's why CMF's player doesn't work as well. The players are identical.

Any idea if this could be due to https://github.com/OpenMPT/openmpt or https://github.com/deskjet/chiptune2.js?

On point. I believe that it's an optimization issue about OpenMPT or the chiptune library. Modarchive.org uses a modified version of chiptune2 afaik.

Also some Android browsers play the track very choppy or don't play it at all.

I tried this demo in Safari and it works: https://deskjet.github.io/chiptune2.js/#

We have to get to the bottom of this. Unfortunately I and @bufgix couldn't have the time to really dive into the OpenMPT and see what's going on under the hood. We're still lack of knowledge and data.

Good thing that somebody pointed this out again :p

sanindya-iiitd commented 3 years ago

Problem: Screenshot 2020-10-23 at 2 59 44 AM

Solution: https://stackoverflow.com/questions/28364122/how-do-i-determine-which-audiocontext-constructor-to-use-in-safari

...and it doesn't work. :P

sanindya-iiitd commented 3 years ago

Screenshot 2020-10-23 at 3 28 51 AM

Can play .s3m files in Safari though. I downloaded a file (shock09.mod) from modarchive and uploaded into https://deskjet.github.io/chiptune2.js/# and it plays fine.

Weird.

sanindya-iiitd commented 3 years ago

Screenshot 2020-10-23 at 3 31 42 AM

Can surprisingly play mod files too now (in Safari, yes).

Weirder.

sanindya-iiitd commented 3 years ago

I tried setting up in my local:

npm install
npm run build
npm run start

homepage loads. But, as soon as I click on "randombtn" like "Where the mods at?", it crashes. Page says: An unexpected error has occurred.

Console shows this:

framework.e11e4af83f0aa0812396.js:formatted:5405 TypeError: Cannot read property 'replace' of undefined
    at index-c8dde9fa7d0c5cb71134.js:1
    at Ye (index-c8dde9fa7d0c5cb71134.js:1)
    at Je (index-c8dde9fa7d0c5cb71134.js:1)
    at qi (framework.e11e4af83f0aa0812396.js:formatted:4029)
    at yo (framework.e11e4af83f0aa0812396.js:formatted:6800)
    at su (framework.e11e4af83f0aa0812396.js:formatted:6343)
    at uu (framework.e11e4af83f0aa0812396.js:formatted:6336)
    at eu (framework.e11e4af83f0aa0812396.js:formatted:6113)
    at framework.e11e4af83f0aa0812396.js:formatted:3291
    at t.unstable_runWithPriority (framework.e11e4af83f0aa0812396.js:formatted:306)

I have no clue how to deal with this (haven't worked with front-end like ever). Any leads?

Or any tips on how to set this in local?

orhun commented 3 years ago

I used yarn for development. So basically run yarn for resolving dependencies and yarn dev for starting the development server. Only issue is yarn.lock being outdated right now. (We should yarn upgrade and fix errors ASAP @bufgix) But I don't think it will affect you since current state of the repository should build just fine.

Does changing the audio context affect the other platforms and have you had the chance to test them?

And yes, unfortunately different formats behave differently. I'm still sus of OpenMPT about that. I gues we can never know without further testing and a bit of code-diving.

sanindya-iiitd commented 3 years ago

I used yarn for development. So basically run yarn for resolving dependencies and yarn dev for starting the development server.

Thanks. I was running into issues with markdown-to-jsx (Help.md linked with BackSideContent). I came across the meta, viewport tags issue and followed this fix but in vain. Eventually, I just replaced <BackSide content={backSideContent} /> with <BackSide content="Sample Help." /> and it worked. (It was maybe due to the github credentials used to fetch Help.md.)

Does changing the audio context affect the other platforms and have you had the chance to test them?

Meanwhile, I did (accidentally) find a way to make CMF play audio on Safari:

  1. Launch chiptune2-demo and upload a mod file, it will play. (We may pause it.)
  2. Now, go to CMF, it will work just fine. 😄

And yes, unfortunately different formats behave differently. I'm still sus of OpenMPT about that. I gues we can never know without further testing and a bit of code-diving.

I did some code-diving today. And, the problem seems to be with the createScriptProcessor() method. The returned AudioNode object has different property values:

According to W3C Candidate Recommendation and W3C Editor's Draft, we should see the first set.

I noticed, in Safari the onaudioprocess event is never triggered and I think this might be a consequence of the misconfigured AudioNode object.

Another thing I learned, ScriptProcessorNode is to be deprecated in favour of AudioWorkletNode and Safari doesn't support AudioWorkletNode as of now.

Can you suggest how to further investigate why uploading a mod to chiptune demo fixes the playback for CMF? I tried this workaround with local CMF but it didn't work.

orhun commented 3 years ago

Hey again, Sorry for the late reply. Unfortunately we couldn't reproduce the workaround method you mentioned. I personally don't have a proper setup to test the issue but @bufgix checked the audio context and saw the same logs that you referred. At this point I'm not quite sure what else we can do other than re-implementing the chiptune library with the latest version of OpenMPT. I still think we should have to have more knowledge by working on the low-level stuff. Thank you for your efforts regarding to that.