Skip to content

Commit

Permalink
Merge pull request #1795 from cb1kenobi/timob-7129
Browse files Browse the repository at this point in the history
[TIMOB-7129] Updated Ti.Media docs and added vibrate().
  • Loading branch information
nebrius committed Mar 22, 2012
2 parents 6719ed6 + a214e5e commit 51cc9dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
11 changes: 7 additions & 4 deletions apidoc/Titanium/Media/Media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |
as playing audio or recording video.
extends: Titanium.Module
since: "0.1"
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, mobileweb]
methods:
- name: beep
summary: Plays a device beep notification.
Expand Down Expand Up @@ -149,7 +149,8 @@ methods:
- name: vibrate
summary: Makes the device vibrate.
description: |
On Android, a `pattern` argument can be provided to specify a vibration pattern.
On Android and Mobile Web, a `pattern` argument can be provided to specify a
vibration pattern.
The `pattern` is an array of Number values. Each number in the array is
interpreted as a duration in milliseconds. The first number is the *delay*
Expand All @@ -159,13 +160,15 @@ methods:
[ 0, 500, 100, 500, 100, 500 ]
Would cause the vibration to start immediately (delay = 0), and perform three
long vibrations (500 ms) separated by short pauses (100ms).
long vibrations (500 ms) separated by short pauses (100ms).
On Mobile Web, calling `vibrate` without a `pattern` will stop the vibration.
parameters:
- name: pattern
summary: Array of values identifying a vibrate pattern (only used on Android).
optional: true
type: Array<Number>
platforms: [iphone, ipad, android]
platforms: [iphone, ipad, android, mobileweb]
events:
- name: linechange
summary: Fired when an audio line type change is detected.
Expand Down
21 changes: 11 additions & 10 deletions mobileweb/titanium/Ti/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {

VIDEO_FINISH_REASON_PLAYBACK_ENDED: 0,
VIDEO_FINISH_REASON_PLAYBACK_ERROR: 1,
VIDEO_FINISH_REASON_USER_EXITED: 2
},
VIDEO_FINISH_REASON_USER_EXITED: 2,

beep: function() {
console.debug('Method "Titanium.Media.beep" is not implemented yet.');
MEDIA_TYPE_PHOTO: "public.image",
MEDIA_TYPE_VIDEO: "public.video"
},

createAudioPlayer: function() {
console.debug('Method "Titanium.Media.createAudioPlayer" is not implemented yet.');
},
//beep: function() {},

createSound: function() {
console.debug('Method "Titanium.Media.createSound" is not implemented yet.');
},
//createAudioPlayer: function() {},

//createSound: function() {},

createVideoPlayer: function(args) {
return new (require("Ti/Media/VideoPlayer"))(args);
},

vibrate: function(pattern) {
"vibrate" in navigator && navigator.vibrate(require.is(pattern, "Array") ? pattern : [pattern | 0]);
}

});
Expand Down

0 comments on commit 51cc9dc

Please sign in to comment.