Menu

#1593 Support sound links in Dictionary pane

5.7
closed-fixed
None
5
2021-11-18
2021-10-03
No

some dictionary (such as DSL) supports sound files.
When supporting <a href="file://bra.wav"> tag to play sound, it would be better.

It can be realized with LinkActionLIstener for dictionary pane.

The issue is related with [bugs:#1065]

    public static class LinkActionListener implements HyperlinkListener {

        @Override
        public void hyperlinkUpdate(final HyperlinkEvent hyperlinkEvent) {
            if (hyperlinkEvent.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                URL url = hyperlinkEvent.getURL();
                if (url.getProtocol().equals("file")) {
                    try {
                        String path = url.toURI().getPath();
                        if (path.endsWith(".wav")) {
                            playSound(new File(path));
                        } 
                    } catch (URISyntaxException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    public static synchronized void playSound(final File file) {
        new Thread(() -> {
            try {
                Clip clip = AudioSystem.getClip();
                AudioInputStream inputStream = AudioSystem.getAudioInputStream(file);
                clip.open(inputStream);
                clip.start();
            } catch (Exception e) {
                System.err.println(e.getMessage());
            }
        }).start();
    }

Discussion

  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -3,7 +3,7 @@
    
     It can be realized with LinkActionLIstener for dictionary pane.
    
    -The issue is related with [#1065]( https://sourceforge.net/p/omegat/bugs/1065/)
    +The issue is related with [bugs:#1065]
    
     ~~~
         public static class LinkActionListener implements HyperlinkListener {
    
     

    Related

    Feature Requests: #1594

  • Aaron Madlon-Kay

    • summary: Support sound link on dictionary pane --> Support sound links in Dictionary pane
    • status: open --> open-fixed
    • assigned_to: Hiroshi Miura
    • Group: 5.6 --> 5.7
     
  • Aaron Madlon-Kay

    This was implemented in [91d272] on master.

     

    Related

    Commit: [91d272]

  • Aaron Madlon-Kay

    • status: open-fixed --> closed-fixed
     
  • Aaron Madlon-Kay

    Implemented in OmegaT 5.7.0.

     

Log in to post a comment.