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

International character support - check if the URI conversions are still needed #1142

Open
caprica opened this issue May 7, 2022 · 6 comments

Comments

@caprica
Copy link
Owner

caprica commented May 7, 2022

This was required with early versions of vlcj e.g. when Windows XP was current.

Now, Windows 10 is a reasonable baseline and UTF-8 should be handled everywhere (?).

Check whether the URI conversions for MRL's is still required or not.

This has always just worked in Linux.

@caprica caprica added the Task label May 7, 2022
@caprica caprica added this to the vlcj 5.0.0 Release milestone May 7, 2022
@caprica caprica changed the title Check if the URI conversions are still needed International character support - check if the URI conversions are still needed Jun 18, 2022
@caprica
Copy link
Owner Author

caprica commented Jun 18, 2022

Given these three test filenames:

  • hello.mp3
  • サンプル.mp3
  • привет.mp3

And the following example code:

package test;

import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.binding.internal.*;
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
import uk.co.caprica.vlcj.media.MediaParsedStatus;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;

public class Main {

    private static libvlc_instance_t instance;

    public static void main(String[] args) throws Exception {
        new MediaPlayerFactory(); // Only for discovery

        instance = LibVlc.libvlc_new(0, null);

        parse("hello.mp3");
        parse("サンプル.mp3");
        parse("привет.mp3");
        parse("nothing.mp3");

        LibVlc.libvlc_release(instance);
    }

    private static void parse(String mrl) throws Exception {
        libvlc_media_t media = LibVlc.libvlc_media_new_path(instance, mrl);

        CountDownLatch latch = new CountDownLatch(1);
        AtomicReference<MediaParsedStatus> parseResult = new AtomicReference<>();

        libvlc_callback_t cb = (event, pointer) -> {
            int newStatus = ((media_parsed_changed) event.u.getTypedValue(media_parsed_changed.class)).new_status;
            parseResult.set(MediaParsedStatus.mediaParsedStatus(newStatus));
            latch.countDown();
        };

        libvlc_event_manager_t eventManager = LibVlc.libvlc_media_event_manager(media);
        LibVlc.libvlc_event_attach(eventManager, libvlc_event_e.libvlc_MediaParsedChanged.intValue(), cb, null);

        LibVlc.libvlc_media_parse_with_options(media, 0, 0);
        latch.await();

        System.out.printf("PARSE RESULT FOR '%s' is %s%n", mrl, parseResult.get());

        LibVlc.libvlc_event_detach(eventManager, libvlc_event_e.libvlc_MediaParsedChanged.intValue(), cb, null);
        LibVlc.libvlc_media_release(media);
    }
}

Create/copy/rename an mp3 file for each of those names, and run the given code.

With JDK 11 on Windows 10+ this just works without any special handling.

@caprica
Copy link
Owner Author

caprica commented Jun 18, 2022

That deals with local files, URL's still need to be checked - but really UNICODE in URL's should not be a concern of vlcj or LibVLC should it?

@caprica
Copy link
Owner Author

caprica commented Jul 4, 2022

Tested URLs and it all seems to work.

@caprica
Copy link
Owner Author

caprica commented Jul 4, 2022

Summary:

  • Tested on Linux and Windows 10 (using Java 18).
  • Tested local files with Unicode characters
  • Tested URLs with Unicode characters and played via an embedded web server

It all appears to work.

Still need to test on macOS.

@caprica
Copy link
Owner Author

caprica commented Jul 4, 2022

It would appear, so far at least, that the special Unicode handling should be removed from vlcj.

@caprica
Copy link
Owner Author

caprica commented Jul 10, 2022

The sample code is out-of-date with respect to native API changes around media.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant