• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to get default media player name of the OS?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I am wondering how to get the default media player name (and its full path if possible) on the target operating system?

For example, if Windows Media Player is the default on Windows, the program will return "wmplayer.exe",... something like that.

I need you help and suggestion.

Thanks.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no such thing as the default media player. There are default applications for file types, and the OS has a mapping for media file types to what you call the default media player. However, it's quite possible to have one media player for one media file type and another media player for another media file type.

If you want to open a file in the default application, you should check out java.awt.Desktop and its open method.
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:There is no such thing as the default media player. There are default applications for file types, and the OS has a mapping for media file types to what you call the default media player. However, it's quite possible to have one media player for one media file type and another media player for another media file type.

If you want to open a file in the default application, you should check out java.awt.Desktop and its open method.



Thanks for your quick reply. okay, it is the default application that I want to mean.
So how to get the name of the default application that is going to open my file?
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to access the Windows registry, or the appropriate configuration files on Linux / Mac OS (no idea which ones).

But why do you need it? If you need to open a file with its default application you should use java.awt.Desktop as I already suggested.
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:You will need to access the Windows registry, or the appropriate configuration files on Linux / Mac OS (no idea which ones).

But why do you need it? If you need to open a file with its default application you should use java.awt.Desktop as I already suggested.



I need the name of the application to pass the URL as an argument to it, because I want to play a video from a URL.
The java.awt.Desktop's open method works nicely with local file, but for URL it opens a browser window which is not what I expect.
 
Bartender
Posts: 15737
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can download the file first, save it in some temporary folder and then pass it to the Desktop class.
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm with Stephan. What if the default player doesn't support playing media from URLs?
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:You can download the file first, save it in some temporary folder and then pass it to the Desktop class.



I thought like you before, but the problem is the video file is usually big and it takes a while to be downloaded, whilst the media player can buffer and play the media without need to download the whole file first.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic