Simple Mediaplayer Play Mp3 from File Path

Simple mediaplayer play mp3 from file path?

It works like this:

mpintro = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Music/intro.mp3"));
mpintro.setLooping(true);
mpintro.start();

It did not work properly as string filepath...

How to play local mp3 files with MediaElement

You might want to check out this code. It worked just fine for me :)

mediaElement1.LoadedBehavior = MediaState.Manual;
mediaElement1.Source = new Uri(@"D:/ExamplePath/myVideoFile.avi");
//@ means that the string behind is a path so / won't be
//treated like a special character
mediaElement1.Play();

How to play one MP3 file after the other using Windows Media Player?

Just make an .M3U playlist. You might also find it useful to let the user browse for the album folder rather than asking him to type it.

@echo off
setlocal

path %PATH%;"%PROGRAMFILES(x86)%\Windows Media Player"

rem // folder chooser: https://stackoverflow.com/q/15885132/1683264
set "psCommand=powershell -noprofile "(new-object -COM Shell.Application)^
.BrowseForFolder(0,\"Please choose your album folder.\",0,0).self.path""
for /f "delims=" %%I in ('%psCommand%') do set "folder=%%I"

>"%temp%\playlist.m3u" (for /r "%folder%" %%I in (*.mp3 *.m4a *.ogg *.flac) do echo %%~fI)

start "" wmplayer "%temp%\playlist.m3u"

Playing a MP3 File from a chosen Directory

Use

Media song = new Media(new File(path).toURI().toString());

I strongly recommend you construct the file in a platform independent way, however, instead of hard-coding a file separator specific to one particular file system. You can do

File path = new File(absolutePath, file);
Media song = new Media(path.toURI().toString());

Does MediaPlayer only play mp3 files that have bit rate mode: variable?

is there a way to find an audio files Bit Rate Mode using java?

You use MediaInfo graphical interface for spotting the issue, you can also use its command line interface (calling a command line from Java) or its library (DyLib) interface (calling an API from Java).

Get the Command line interface or the DyLib interface from MediaInfo macOS version, then call the command line or get the "glue" between Java and MediaInfo + implement Java calls to MediaInfo.

Android Media Player cannot play audio file by the path

define permission in manifest file, and check and request to permission before play media, don't deny external storage permission because we play media from internal storage and parse into URI.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
musicUrl = "yourURL";
try {
mPlayer.setDataSource(getContext(), Uri.parse(musicUrl));
mPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}


Related Topics



Leave a reply



Submit