• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 22803
131
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: 22803
131
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.
 
Saloon Keeper
Posts: 15714
367
  • 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: 22803
131
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.
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic