Skip to content

Commit 4b09af2

Browse files
authored
Merge branch 'master' into master
2 parents 1313861 + a006da3 commit 4b09af2

40 files changed

+917
-10844
lines changed

.appveyor.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# appveyor file
2+
# http://www.appveyor.com/docs/appveyor-yml
3+
4+
max_jobs: 1
5+
6+
shallow_clone: true
7+
8+
init:
9+
- git config --global core.autocrlf true
10+
11+
image:
12+
- Visual Studio 2017
13+
14+
environment:
15+
nodejs_version: "4"
16+
matrix:
17+
- PLATFORM: windows-10-store
18+
JUST_BUILD: --justBuild
19+
install:
20+
- npm cache clean -f
21+
- node --version
22+
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
23+
- npm install -g cordova
24+
25+
build: off
26+
27+
test_script:
28+
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Thanks!
1717

1818

1919
### Checklist
20-
- [ ] [ICLA](http://www.apache.org/licenses/icla.txt) has been signed and submitted to [email protected].
2120
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
2221
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
2322
- [ ] Added automated test coverage as appropriate for this change.

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ Thumbs.db
1414

1515
node_modules
1616

17+
#eclipse
18+
bin
19+
.project
20+
.classpath
1721

1822

1923

2024

2125

22-
23-
26+

.travis.yml

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,86 @@
1-
language: node_js
21
sudo: false
3-
node_js:
4-
- "4.2"
2+
addons:
3+
jwt:
4+
secure: M4uBGUMbanDtCBrNktJhEwNSLL0UsOV3IoINqW3GRupX7Mr13MBZzsORm4HVbdbPxQ6Bf2LhyJ/fabQRsOoJrCokgWwfKkigztQcMFeLNao9liBRA6kuQOh5/rdfoULpu96GvlYzB4ddgSBSSGQW3DesaKC/BpTXnvQ4OnXo5e4=
5+
env:
6+
global:
7+
- SAUCE_USERNAME=snay
8+
- TRAVIS_NODE_VERSION="6.14.2"
9+
matrix:
10+
include:
11+
- env: PLATFORM=browser-chrome
12+
os: linux
13+
language: node_js
14+
node_js: '6.14.2'
15+
- env: PLATFORM=browser-firefox
16+
os: linux
17+
language: node_js
18+
node_js: '6.14.2'
19+
- env: PLATFORM=browser-safari
20+
os: linux
21+
language: node_js
22+
node_js: '6.14.2'
23+
- env: PLATFORM=browser-edge
24+
os: linux
25+
language: node_js
26+
node_js: '6.14.2'
27+
- env: PLATFORM=ios-9.3
28+
os: osx
29+
osx_image: xcode8.3
30+
language: node_js
31+
node_js: '6.14.2'
32+
- env: PLATFORM=ios-10.0
33+
os: osx
34+
osx_image: xcode8.3
35+
language: node_js
36+
node_js: '6.14.2'
37+
- env: PLATFORM=android-4.4
38+
os: linux
39+
language: android
40+
jdk: oraclejdk8
41+
android:
42+
components:
43+
- tools
44+
- build-tools-26.0.2
45+
- env: PLATFORM=android-5.1
46+
os: linux
47+
language: android
48+
jdk: oraclejdk8
49+
android:
50+
components:
51+
- tools
52+
- build-tools-26.0.2
53+
- env: PLATFORM=android-6.0
54+
os: linux
55+
language: android
56+
jdk: oraclejdk8
57+
android:
58+
components:
59+
- tools
60+
- build-tools-26.0.2
61+
- env: PLATFORM=android-7.0
62+
os: linux
63+
language: android
64+
jdk: oraclejdk8
65+
android:
66+
components:
67+
- tools
68+
- build-tools-26.0.2
69+
before_install:
70+
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
71+
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
72+
install $TRAVIS_NODE_VERSION
73+
- node --version
74+
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
75+
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
76+
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
77+
fi
78+
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
79+
&& npm install && popd
80+
- npm install -g cordova
81+
install:
82+
- npm install
83+
script:
84+
- npm test
85+
- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
86+
--buildName travis-plugin-media-$TRAVIS_JOB_NUMBER

README.md

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ description: Record and play audio on the device.
2121
# under the License.
2222
-->
2323

24-
[![Build Status](https://travis-ci.org/apache/cordova-plugin-media.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-media)
24+
|AppVeyor|Travis CI|
25+
|:-:|:-:|
26+
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-media?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-media)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-media.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-media)|
2527

2628
# cordova-plugin-media
2729

@@ -44,7 +46,7 @@ function onDeviceReady() {
4446
}
4547
```
4648

47-
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Media%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
49+
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22cordova-plugin-media%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
4850

4951

5052
## Installation
@@ -56,18 +58,10 @@ cordova plugin add cordova-plugin-media
5658
## Supported Platforms
5759

5860
- Android
59-
- BlackBerry 10
6061
- iOS
61-
- Windows Phone 7 and 8
62-
- Tizen
63-
- Windows 8
6462
- Windows
6563
- Browser
6664

67-
## Windows Phone Quirks
68-
69-
- Only one media file can be played back at a time.
70-
7165
## Media
7266

7367
```js
@@ -80,9 +74,9 @@ var media = new Media(src, mediaSuccess, [mediaError], [mediaStatus]);
8074

8175
- __mediaSuccess__: (Optional) The callback that executes after a `Media` object has completed the current play, record, or stop action. _(Function)_
8276

83-
- __mediaError__: (Optional) The callback that executes if an error occurs. _(Function)_
77+
- __mediaError__: (Optional) The callback that executes if an error occurs. It takes an integer error code. _(Function)_
8478

85-
- __mediaStatus__: (Optional) The callback that executes to indicate status changes. _(Function)_
79+
- __mediaStatus__: (Optional) The callback that executes to indicate status changes. It takes a integer status code. _(Function)_
8680

8781
__NOTE__: `cdvfile` path is supported as `src` parameter:
8882
```javascript
@@ -102,7 +96,7 @@ The following constants are reported as the only parameter to the
10296

10397
### Methods
10498

105-
- `media.getCurrentAmplitude`: Returns the current position within an audio file.
99+
- `media.getCurrentAmplitude`: Returns the current amplitude within an audio file.
106100

107101
- `media.getCurrentPosition`: Returns the current position within an audio file.
108102

@@ -128,6 +122,8 @@ The following constants are reported as the only parameter to the
128122

129123
- `media.stop`: Stop playing an audio file.
130124

125+
- `media.setRate`: Set the playback rate for the audio file.
126+
131127
### Additional ReadOnly Parameters
132128

133129
- __position__: The position within the audio playback, in seconds.
@@ -138,7 +134,7 @@ The following constants are reported as the only parameter to the
138134

139135
## media.getCurrentAmplitude
140136

141-
Returns the current amplitude of the current recording.
137+
Returns the current amplitude within an audio file.
142138

143139
media.getCurrentAmplitude(mediaSuccess, [mediaError]);
144140

@@ -310,7 +306,7 @@ function recordAudio() {
310306

311307
// Pause Recording after 5 seconds
312308
setTimeout(function() {
313-
my_media.pauseRecord();
309+
mediaRec.pauseRecord();
314310
}, 5000);
315311
}
316312
```
@@ -358,8 +354,11 @@ function playAudio(url) {
358354
is locked. If set to `true` (the default value), the state of the
359355
hardware mute button is ignored, e.g.:
360356

361-
var myMedia = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3")
362-
myMedia.play({ playAudioWhenScreenIsLocked : false })
357+
var myMedia = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
358+
myMedia.play({ playAudioWhenScreenIsLocked : true });
359+
myMedia.setVolume('1.0');
360+
361+
> Note: To allow playback with the screen locked or background audio you have to add `audio` to `UIBackgroundModes` in the `info.plist` file. See [Apple documentation](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW23). Also note that the audio has to be started before going to background.
363362
364363
- __order of file search__: When only a file name or simple path is
365364
provided, iOS searches in the `www` directory for the file, then in
@@ -425,12 +424,12 @@ function recordAudio() {
425424

426425
// Pause Recording after 5 seconds
427426
setTimeout(function() {
428-
my_media.pauseRecord();
427+
mediaRec.pauseRecord();
429428
}, 5000);
430429

431430
// Resume Recording after 10 seconds
432431
setTimeout(function() {
433-
my_media.resumeRecord();
432+
mediaRec.resumeRecord();
434433
}, 10000);
435434
}
436435
```
@@ -459,10 +458,6 @@ setTimeout(function() {
459458
}, 5000);
460459
```
461460

462-
### BlackBerry 10 Quirks
463-
464-
- Not supported on BlackBerry OS 5 devices.
465-
466461
## media.setVolume
467462

468463
Set the volume for an audio file.
@@ -520,7 +515,6 @@ Starts recording an audio file.
520515

521516
- Android
522517
- iOS
523-
- Windows Phone 7 and 8
524518
- Windows
525519

526520
### Quick Example
@@ -548,19 +542,33 @@ function recordAudio() {
548542

549543
### Android Quirks
550544

551-
- Android devices record audio in Adaptive Multi-Rate format. The specified file should end with a _.amr_ extension.
545+
- Android devices record audio in AAC ADTS file format. The specified file should end with a _.aac_ extension.
552546
- The hardware volume controls are wired up to the media volume while any Media objects are alive. Once the last created Media object has `release()` called on it, the volume controls revert to their default behaviour. The controls are also reset on page navigation, as this releases all Media objects.
553547

554548
### iOS Quirks
555549

556-
- iOS only records to files of type _.wav_ and returns an error if the file name extension is not correct.
550+
- iOS only records to files of type _.wav_ and _.m4a_ and returns an error if the file name extension is not correct.
557551

558552
- If a full path is not provided, the recording is placed in the application's `documents/tmp` directory. This can be accessed via the `File` API using `LocalFileSystem.TEMPORARY`. Any subdirectory specified at record time must already exist.
559553

560554
- Files can be recorded and played back using the documents URI:
561555

562556
var myMedia = new Media("documents://beer.mp3")
563557

558+
- Since iOS 10 it's mandatory to provide an usage description in the `info.plist` if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description.
559+
560+
This plugins requires the following usage description:
561+
562+
* `NSMicrophoneUsageDescription` describes the reason that the app accesses the user's microphone.
563+
564+
To add this entry into the `info.plist`, you can use the `edit-config` tag in the `config.xml` like this:
565+
566+
```
567+
<edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
568+
<string>need microphone access to record sounds</string>
569+
</edit-config>
570+
```
571+
564572
### Windows Quirks
565573

566574
- Windows devices can use MP3, M4A and WMA formats for recorded audio. However in most cases it is not possible to use MP3 for audio recording on _Windows Phone 8.1_ devices, because an MP3 encoder is [not shipped with Windows Phone](https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.mediaproperties.mediaencodingprofile.createmp3.aspx).
@@ -569,10 +577,6 @@ function recordAudio() {
569577

570578
- Any subdirectory specified at record time must already exist.
571579

572-
### Tizen Quirks
573-
574-
- Not supported on Tizen devices.
575-
576580
## media.stop
577581

578582
Stops playing an audio file.
@@ -617,7 +621,6 @@ Stops recording an audio file.
617621

618622
- Android
619623
- iOS
620-
- Windows Phone 7 and 8
621624
- Windows
622625

623626
### Quick Example
@@ -649,9 +652,33 @@ function recordAudio() {
649652
}
650653
```
651654

652-
### Tizen Quirks
655+
## media.setRate
656+
657+
Stops recording an audio file.
658+
659+
media.setRate(rate);
653660

654-
- Not supported on Tizen devices.
661+
### Supported Platforms
662+
663+
- iOS
664+
665+
### Parameters
666+
667+
- __rate__: The rate to set for playback.
668+
669+
### Quick Example
670+
671+
```js
672+
// Audio player
673+
//
674+
var my_media = new Media(src, onSuccess, onError);
675+
my_media.play();
676+
677+
// Set playback rate to 2.0x after 10 seconds
678+
setTimeout(function() {
679+
my_media.setRate(2.0);
680+
}, 5000);
681+
```
655682

656683
## MediaError
657684

0 commit comments

Comments
 (0)