Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f846455

Browse files
Add support to play filename starting with "file://" (zmxv#528)
* Build library to support file:/ pattern * Revert "Build library to support file:/ pattern" This reverts commit a20701a. * Fix to support path starting with file:/
1 parent 87ae91b commit f846455

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎android/src/main/java/com/zmxv/RNSound/RNSoundModule.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ protected MediaPlayer createMediaPlayer(final String fileName) {
192192
}
193193
}
194194

195+
if (fileName.startsWith("file:/")){
196+
try {
197+
mediaPlayer.setDataSource(fileName);
198+
} catch(IOException e) {
199+
Log.e("RNSoundModule", "Exception", e);
200+
return null;
201+
}
202+
return mediaPlayer;
203+
}
204+
195205
File file = new File(fileName);
196206
if (file.exists()) {
197207
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

‎sound.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var eventEmitter = new ReactNative.NativeEventEmitter(RNSound);
1010
var nextKey = 0;
1111

1212
function isRelativePath(path) {
13-
return !/^(\/|http(s?)|asset)/.test(path);
13+
return !/^(\/|http(s?)|asset|file)/.test(path);
1414
}
1515

1616
function calculateRelativeVolume(volume, pan) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /