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

Playback audio file is no longer working #1320

Closed
Borewit opened this issue Feb 5, 2018 · 3 comments
Closed

Playback audio file is no longer working #1320

Borewit opened this issue Feb 5, 2018 · 3 comments

Comments

@Borewit
Copy link
Member

Borewit commented Feb 5, 2018

What version of WebTorrent Desktop? (See the 'About WebTorrent' menu)
Version 0.19.0 (0.98.21) (64-bit)

What operating system and version?
Microsoft Windows [Version 10.0.16299.192]

What did you do?

  1. Downloaded a audio music album
  2. Clicked the music album (torrent), went to the file (track) list
  3. Clicked one of the tracks in order to play it (tried: FLAC & MP3)

What did you expect to happen?
I would expect:

  1. To see the covert art displayed on the background
  2. Metadata of the audio track to appear in the center of the window
  3. The audio track to play

What actually happened?

  1. Window remains black
  2. Audio did not play
@Borewit
Copy link
Member Author

Borewit commented Feb 5, 2018

I suspect the issue is caused in:

musicmetadata(file.createReadStream(), function (err, info) {
if (err) return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
const { artist, album, albumartist, title, year, track, disk, genre } = info
const importantInfo = { artist, album, albumartist, title, year, track, disk, genre }
console.log('got audio metadata for %s: %o', file.name, importantInfo)
ipc.send('wt-audio-metadata', infoHash, index, importantInfo)
})

Applying pull request #1240 resolves the cover art problem and does play the track, but the meta-data problem remains (...meta-data of the audio track to appear in the center of the window).

I suspect there is an interoperability issue between the torrent stream and the library handling.

Using the music-metadata module it possible, in addition to stream based reading, to use direct file access. If the file has completed downloading, that could be used instead:

function getAudioMetadata (infoHash, index) {
  const torrent = client.get(infoHash)
  const file = torrent.files[index]

  const options = {native: false, skipCovers: true}
  const onMetaData = file.done
        // If completed; use direct file access
        ? mm.parseFile(path.join(torrent.path, file.path), options)
        // otherwise stream
        : mm.parseStream(file.createReadStream(), file.name, options)

  onMetaData
        .then(function (metadata) {
          console.log('got audio metadata for %s: %o', file.name, metadata)
          ipc.send('wt-audio-metadata', infoHash, index, metadata)
        }).catch(function (err) {
          return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
        })
}

This fixes the meta-data of the audio track to appear in the center of the window if the file is completed:

I know for for a fact that the old musicmetadata module, as used on the master branch, does not properly implement NodeJS streams. I have not been able able to figure out why the mm.parseStream no longer works with the music-metadata. I have a hard capturing breakpoints in the WebTorrent Hidden Window using IntelliJ.

@Borewit
Copy link
Member Author

Borewit commented Feb 5, 2018

I think I got the lost issue (torrent-file-stream not working with music-metadata). I suspect it is caused by an error thrown in then-read-stream

    if (!(s instanceof stream.Readable)) {
      throw new Error("Expected an instance of stream.Readable");

because webtorrent is using the readable-stream module.

Bug reported against my own repo Borewit/peek-readable#4

Borewit added a commit to Borewit/peek-readable that referenced this issue Feb 5, 2018
Borewit added a commit to Borewit/strtok3 that referenced this issue Feb 5, 2018
Update dependencies.
Update then-read-stream to address issue webtorrent/webtorrent-desktop#1320
Borewit added a commit to Borewit/music-metadata that referenced this issue Feb 5, 2018
Had to adjust some Promise types and includes :-(
Updated strtok3 should resolve issue webtorrent/webtorrent-desktop#1320
@Borewit Borewit changed the title Playback audio is no longer working Playback audio file is no longer working Feb 6, 2018
@Borewit
Copy link
Member Author

Borewit commented Mar 4, 2018

I manage to play audio tracks using the master branch code.

I guess I made mistake somewhere switching between from my development branch back to the master branch.

@Borewit Borewit closed this as completed Mar 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant