4

I have been stalking this great site for ages. Today I finally decided to create an account when I got stuck on a problem.

My problem is rather basic vlcj executing. I have a program running as an audio player. It is all done except for one problem I cannot seem to figure out.

When someone tried to play a song with a 'é' (e with acute) in the filepath, it seems to translate wrong into the system of vlcj.

Example: I run:

mediaPlayerComponent.getMediaPlayer().playMedia("file:///C:\\test.mp3");
  //(where mediaPlayerComponentis my is my local instantiated 
  // EmbeddedMediaPlayerComponent) 

And this plays fine. But if I run:

mediaPlayerComponent.getMediaPlayer().playMedia("file:///C:\\é.mp3");

It does not run anything.

  • If I call startMedia instead of playMedia, the boolean return value is false.

  • I also tried it without the 'file:///' in front of it, this doesnt functionally change a thing, except if I kill the program, then I get a 'libdvdread' error messages such as:

    libdvdread: Could not open C:\?.mp3 with libdvdcss.
    

So to make the question short and sweet: How do I supply the correct 'mrl' to make vlcj play my 'é.mp3'. And/or which MediaOptions are needed to parse the correct encoding (I am assuming my error is here?)

Preemptively sorry for not supplying an SSCCE, I do not think it will be relevant. Thank you for your time.

  • If you simply run the `file:///C:\\é.mp3` directly from VLC media player instead of your VLCJ application, does it work? If it does, then try to perform URI/URL encoding upon the filepath before passing it to VLCJ's playMedia() – ee. Jul 17 '12 at 06:31
  • I forgot to mention (derp.), running directly from VLC or from Winamp for that matter properly does execute the file. As does renaming it, and then running it. So I do think it has to do with the string encoding. I will give it a try when I got time to get back to this project later tonight. Thank you. – Karl Stönniger Jul 18 '12 at 13:31
  • I tried various setups with encoding it with latin1, UTF-8, UTF-16, Windows-1252 and us-ascii. I have not had success so far. I did notice that when using the us-ascii encoding, the value changes into a similar value which is returned from the 'libdvdread' error parser. – Karl Stönniger Jul 20 '12 at 08:50

3 Answers3

0

After some interlude I finally found out what went wrong. Apperantly, under windows international characters arent really parsed very well into VLCJ. By adding:

<jvmarg value="-Dvlcj.log=DEBUG>

to my ANT-run script, I suddenly could play files with an e-acute. Apperantly the decoder of the JVM is finalized when initializing.

Hope this helps someone :-)

  • I'm on this exact same issue, thanks for sharing! However adding this arg in my run configs doesn't work for me, still won't play the video or generate a thumbnail if there's an e-acute in the filepath. If I add a "%" (yerr I know it should not be, but it's allowed so it will happen), it's event worst, the JVM crashes completely due to VLC getting a fatal error lol. Did you find a way to get this to work ? Thanks in advance. – Frederik.L Aug 14 '12 at 07:02
  • Adding the argument worked for me (although I had to rewrite another part of the program which used static strings? wierd.). After I added the argument, I could truncate my 'play' script back down to: EmbeddedMediaPlayerComponent mediaPlayerComponent; /* already initialised at this point in runtime */ mediaPlayerComponent.getMediaPlayer().playMedia((String)trackFile); I am only trying to play mp3's with this script, though. So I do not know about previews or anything of the sorts. Hope this helps! – Karl Stönniger Aug 14 '12 at 15:06
  • Supplemental: Also, a percent sign needs to be escaped in utf-8, if I recall correctly :-) A quick google led me to this wiki page: http://en.wikipedia.org/wiki/Percent-encoding I think the '%' sign might try to resolve to one of the characters defined under the paragraph: 'Percent-encoding reserved characters'. But I am not certain. Good luck! – Karl Stönniger Aug 14 '12 at 15:12
0

This is transparently handled in vlcj 2.4.0 onwards by detecting local filenames that contain Unicode characters and converting those filenames to percent-encoded file URLs.

So with current versions of vlcj you should be able to simply pass your filename containing international characters directly to mediaPlayer.playMedia(...).

caprica
  • 3,902
  • 4
  • 19
  • 39
0

I found the solution here:

https://github.com/caprica/vlcj/issues/415

This work for me on mac and on windows (vlcj-3.7.0) :

  public void play(String mrlPathFile) {
    // URI encode for avoid non ascii character problem in windows!!!
    mrlPathFile = new File(mrlPathFile).toURI().toASCIIString().replace("file:/", "file:///");
    mediaPlayer.playMedia(mrlPathFile);
}

I this could help anyone :)

aurox
  • 107
  • 1
  • 3
  • 8