@maccesar/titools 5.2.5 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -1
- package/README.md +58 -97
- package/agents/ti-pro.md +4 -2
- package/commands/ti-audit.md +7 -5
- package/docs/examples.md +24 -13
- package/docs/knowledge-index.md +2 -1
- package/lib/config.js +1 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +18 -179
- package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
- package/skills/alloy-guides/references/CONCEPTS.md +27 -162
- package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
- package/skills/alloy-guides/references/MODELS.md +47 -723
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
- package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
- package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
- package/skills/alloy-guides/references/WIDGETS.md +49 -127
- package/skills/alloy-howtos/SKILL.md +14 -169
- package/skills/alloy-howtos/references/best_practices.md +9 -113
- package/skills/alloy-howtos/references/cli_reference.md +18 -223
- package/skills/alloy-howtos/references/config_files.md +50 -133
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
- package/skills/alloy-howtos/references/samples.md +21 -138
- package/skills/ti-api/SKILL.md +10 -2
- package/skills/ti-api/references/api-android.md +36 -2
- package/skills/ti-api/references/api-app-platform.md +39 -3
- package/skills/ti-api/references/api-core.md +50 -18
- package/skills/ti-api/references/api-data-network.md +49 -35
- package/skills/ti-api/references/api-media.md +45 -27
- package/skills/ti-api/references/api-services.md +39 -9
- package/skills/ti-api/references/api-ui-android.md +33 -13
- package/skills/ti-api/references/api-ui-extras.md +41 -15
- package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
- package/skills/ti-api/references/api-ui-ios.md +74 -2
- package/skills/ti-api/references/api-ui-lists.md +32 -16
- package/skills/ti-api/references/api-ui-text-input.md +34 -17
- package/skills/ti-api/references/api-ui-views.md +27 -1
- package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
- package/skills/ti-api/references/api-xml-global.md +66 -16
- package/skills/ti-create-release/SKILL.md +98 -0
- package/skills/ti-create-release/references/module-discovery.md +69 -0
- package/skills/ti-expert/references/adaptive-layouts.md +1 -1
- package/skills/ti-guides/SKILL.md +37 -76
- package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
- package/skills/ti-guides/references/android-manifest.md +24 -83
- package/skills/ti-guides/references/app-distribution.md +31 -377
- package/skills/ti-guides/references/application-frameworks.md +127 -335
- package/skills/ti-guides/references/cli-reference.md +184 -633
- package/skills/ti-guides/references/commonjs-advanced.md +81 -231
- package/skills/ti-guides/references/compatibility-matrix.md +36 -75
- package/skills/ti-guides/references/hello-world.md +95 -70
- package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
- package/skills/ti-guides/references/resources.md +174 -142
- package/skills/ti-guides/references/sdk-release-notes.md +28 -71
- package/skills/ti-guides/references/tiapp-config.md +222 -598
- package/skills/ti-howtos/SKILL.md +23 -123
- package/skills/ti-howtos/references/cross-platform-development.md +119 -324
- package/skills/ti-howtos/references/debugging-profiling.md +77 -445
- package/skills/ti-howtos/references/extending-titanium.md +199 -673
- package/skills/ti-howtos/references/local-data-sources.md +87 -300
- package/skills/ti-howtos/references/location-and-maps.md +86 -213
- package/skills/ti-howtos/references/media-apis.md +103 -223
- package/skills/ti-howtos/references/notification-services.md +86 -506
- package/skills/ti-howtos/references/remote-data-sources.md +97 -316
- package/skills/ti-howtos/references/using-modules.md +77 -133
- package/skills/ti-synthengine/SKILL.md +62 -111
- package/skills/ti-synthengine/assets/example/README.md +50 -59
- package/skills/ti-synthengine/assets/example/app.js +67 -65
- package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
- package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
- package/skills/ti-synthengine/assets/index.d.ts +122 -2
- package/skills/ti-synthengine/references/advanced-examples.md +4 -4
- package/skills/ti-synthengine/references/api.md +40 -18
- package/skills/ti-synthengine/references/audio-engine.md +15 -57
- package/skills/ti-synthengine/references/examples.md +63 -6
- package/skills/ti-synthengine/references/guide.md +61 -57
- package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
- package/skills/ti-synthengine/references/native-variation.md +53 -14
- package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
- package/skills/ti-synthengine/references/recipes.md +19 -16
- package/skills/ti-synthengine/references/recommendations.md +12 -12
- package/skills/ti-synthengine/references/sound-api.md +197 -0
- package/skills/ti-synthengine/references/sound-design.md +7 -7
- package/skills/ti-synthengine/references/source-notes.md +62 -172
- package/skills/ti-synthengine/references/troubleshooting.md +17 -19
- package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
- package/skills/ti-ui/SKILL.md +28 -143
- package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
- package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
- package/skills/ti-ui/references/listviews-and-performance.md +100 -703
- package/skills/ti-ui/references/platform-conventions.md +180 -0
- package/skills/ti-ui/references/user-interface.md +43 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
- package/skills/alloy-howtos/references/custom_tags.md +0 -148
- package/skills/ti-guides/references/coding-best-practices.md +0 -149
- package/skills/ti-guides/references/javascript-primer.md +0 -414
- package/skills/ti-guides/references/reserved-words.md +0 -36
- package/skills/ti-guides/references/style-and-conventions.md +0 -103
- package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
- package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
- package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
- package/skills/ti-howtos/references/google-maps-v2.md +0 -172
- package/skills/ti-howtos/references/ios-map-kit.md +0 -149
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
- package/skills/ti-howtos/references/tutorials.md +0 -565
- package/skills/ti-howtos/references/web-content-integration.md +0 -287
- package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
- package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
- package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
- package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
- package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
- package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
- package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
- package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
- package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
- package/skills/ti-synthengine/references/performance-review.json +0 -1146
- package/skills/ti-synthengine/references/physical-validation.json +0 -1457
- package/skills/ti-synthengine/references/source-snapshot.json +0 -542
- package/skills/ti-synthengine/references/stats-performance.json +0 -2992
- package/skills/ti-synthengine/references/stats-performance.md +0 -82
- package/skills/ti-synthengine/references/studio-validation.json +0 -6202
- package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
- package/skills/ti-synthengine/references/unified-validation.json +0 -314
- package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
- package/skills/ti-ui/references/animation-and-matrices.md +0 -569
- package/skills/ti-ui/references/application-structures.md +0 -626
- package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
- package/skills/ti-ui/references/event-handling.md +0 -401
- package/skills/ti-ui/references/gestures.md +0 -448
- package/skills/ti-ui/references/orientation.md +0 -374
- package/skills/ti-ui/references/platform-ui-android.md +0 -727
- package/skills/ti-ui/references/platform-ui-ios.md +0 -576
- package/skills/ti-ui/references/scrolling-views.md +0 -288
- package/skills/ti-ui/references/tableviews.md +0 -542
|
@@ -1,268 +1,148 @@
|
|
|
1
|
-
# Media
|
|
1
|
+
# Media
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Based on the [current official guide](https://titaniumsdk.com/docs/build/media.md). Examples target released SDK 13.4.1; verify the selected SDK before adopting version-specific behavior.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Use for short effects, beeps, ambient audio
|
|
7
|
-
- The entire file loads into memory. Use `preload=true` to reduce delay.
|
|
8
|
-
- Methods: `play()`, `pause()`, `stop()`, `setVolume()`
|
|
9
|
-
- `allowBackground=true` keeps playback going when the app closes
|
|
5
|
+
Camera, library access and recording need their matching permissions. Playing an app-owned audio or video file does not itself require camera, microphone or music-library permission.
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
const sound = Ti.Media.createSound({
|
|
13
|
-
url: 'beep.mp3',
|
|
14
|
-
preload: true
|
|
15
|
-
});
|
|
16
|
-
sound.play();
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Streaming audio (Ti.Media.AudioPlayer)
|
|
20
|
-
- Use for streaming web URLs (MP3, HLS)
|
|
21
|
-
- Supports pseudo-streaming and HLS
|
|
22
|
-
- Handle interruptions (phone calls) with app-level events:
|
|
23
|
-
- `pause`: call `setPaused(true)` or `pause()`
|
|
24
|
-
- `resume`: call `setPaused(false)` or `start()`
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
const streamer = Ti.Media.createAudioPlayer({ url: 'https://example.com/stream.mp3' });
|
|
28
|
-
streamer.start();
|
|
29
|
-
|
|
30
|
-
Ti.App.addEventListener('pause', () => { streamer.setPaused(true); });
|
|
31
|
-
Ti.App.addEventListener('resume', () => { streamer.setPaused(false); });
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Recording audio (Ti.Media.AudioRecorder)
|
|
35
|
-
- Requires microphone permission
|
|
36
|
-
- Properties:
|
|
37
|
-
- `compression`: `Ti.Media.AUDIO_FORMAT_ULAW` (low-fi) or `AUDIO_FORMAT_LINEAR_PCM` (hi-fi)
|
|
38
|
-
- `format`: `Ti.Media.AUDIO_FILEFORMAT_WAVE`
|
|
39
|
-
- Methods: `start()`, `pause()`/`resume()`, `stop()`
|
|
40
|
-
|
|
41
|
-
## 2. Video APIs (Ti.Media.VideoPlayer)
|
|
7
|
+
## Ask first
|
|
42
8
|
|
|
43
|
-
|
|
44
|
-
- Android: must be fullscreen (Intent-based, not a view proxy)
|
|
45
|
-
- iOS: can be embedded or fullscreen; set `height` and `width` for embedded
|
|
9
|
+
Each capability has a matching pair of methods.
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```javascript
|
|
54
|
-
const videoPlayer = Ti.Media.createVideoPlayer({
|
|
55
|
-
url: 'movie.mp4',
|
|
56
|
-
scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT // or ASPECT_FILL, MODE_FILL, NONE
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
const player = Ti.Media.createVideoPlayer({
|
|
62
|
-
url: 'movie.mp4',
|
|
63
|
-
movieControlStyle: Ti.Media.VIDEO_CONTROL_EMBEDDED,
|
|
64
|
-
autoplay: true
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// iOS only: add to window
|
|
68
|
-
if (Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'ipad') {
|
|
69
|
-
win.add(player);
|
|
70
|
-
}
|
|
11
|
+
| Capability | Check | Ask |
|
|
12
|
+
| ---------- | ----- | --- |
|
|
13
|
+
| Camera | `Ti.Media.hasCameraPermissions()` | `requestCameraPermissions()` |
|
|
14
|
+
| Photo library | `hasPhotoGalleryPermissions()` | `requestPhotoGalleryPermissions()` |
|
|
15
|
+
| Microphone | `hasAudioRecorderPermissions()` | `requestAudioRecorderPermissions()` |
|
|
16
|
+
| Music library (iOS) | `hasMusicLibraryPermissions()` | `requestMusicLibraryPermissions()` |
|
|
71
17
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- `load`: movie finished loading
|
|
79
|
-
- `fullscreen`: entered/exited fullscreen (check `e.entering`)
|
|
80
|
-
|
|
81
|
-
## 3. Camera and photo gallery APIs
|
|
82
|
-
|
|
83
|
-
### Camera availability and permissions
|
|
84
|
-
Always check device support and permissions before opening the camera:
|
|
85
|
-
|
|
86
|
-
```javascript
|
|
87
|
-
if (!Ti.Media.isCameraSupported) {
|
|
88
|
-
Ti.API.warn('No camera available on this device');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (Ti.Media.hasCameraPermissions()) {
|
|
93
|
-
openCamera();
|
|
94
|
-
} else {
|
|
18
|
+
```js
|
|
19
|
+
function withCamera(done) {
|
|
20
|
+
if (Ti.Media.hasCameraPermissions()) {
|
|
21
|
+
done();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
95
24
|
Ti.Media.requestCameraPermissions((e) => {
|
|
96
25
|
if (e.success) {
|
|
97
|
-
|
|
26
|
+
done();
|
|
98
27
|
} else {
|
|
99
|
-
Ti.API.
|
|
28
|
+
Ti.API.warn('camera denied');
|
|
100
29
|
}
|
|
101
30
|
});
|
|
102
31
|
}
|
|
103
32
|
```
|
|
104
33
|
|
|
105
|
-
|
|
34
|
+
iOS also needs a usage string in `tiapp.xml`, and a missing required usage description can terminate the app when the protected API is accessed:
|
|
106
35
|
|
|
107
36
|
```xml
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
<
|
|
37
|
+
<ios>
|
|
38
|
+
<plist>
|
|
39
|
+
<dict>
|
|
40
|
+
<key>NSCameraUsageDescription</key>
|
|
41
|
+
<string>Attach a photo to a note.</string>
|
|
42
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
43
|
+
<string>Choose a photo to attach to a note.</string>
|
|
44
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
45
|
+
<string>Record a voice note.</string>
|
|
46
|
+
</dict>
|
|
47
|
+
</plist>
|
|
48
|
+
</ios>
|
|
112
49
|
```
|
|
113
50
|
|
|
114
|
-
|
|
115
|
-
- Requires camera permission and usage descriptions
|
|
116
|
-
- Success callback provides `event.media` (Blob)
|
|
117
|
-
- Use `saveToPhotoGallery: true` to auto-save
|
|
118
|
-
- Handle `cancel` and `error` callbacks
|
|
51
|
+
Write the real reason. "Required by the app" is the string reviewers reject.
|
|
119
52
|
|
|
120
|
-
|
|
121
|
-
```javascript
|
|
122
|
-
const cameras = Ti.Media.availableCameras;
|
|
53
|
+
## The camera
|
|
123
54
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Ti.Media.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
55
|
+
```js
|
|
56
|
+
Ti.Media.showCamera({
|
|
57
|
+
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
|
|
58
|
+
saveToPhotoGallery: false,
|
|
59
|
+
success(e) {
|
|
60
|
+
const image = Ti.UI.createImageView({ image: e.media, width: 200, height: 200 });
|
|
61
|
+
win.add(image);
|
|
62
|
+
},
|
|
63
|
+
cancel() {},
|
|
64
|
+
error(e) {
|
|
65
|
+
Ti.API.error(e.error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
134
68
|
```
|
|
135
69
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
| ---------------------- | ----------------------------------------------- |
|
|
139
|
-
| `autohide` | Auto-hide camera after capture (default: true) |
|
|
140
|
-
| `animated` | Animate camera appearance |
|
|
141
|
-
| `allowEditing` | Allow user to crop/edit after capture |
|
|
142
|
-
| `mediaTypes` | Array: `MEDIA_TYPE_PHOTO`, `MEDIA_TYPE_VIDEO` |
|
|
143
|
-
| `videoMaximumDuration` | Max video duration in milliseconds |
|
|
144
|
-
| `videoQuality` | `QUALITY_HIGH`, `QUALITY_MEDIUM`, `QUALITY_LOW` |
|
|
145
|
-
| `overlay` | Custom `Ti.UI.View` overlay on camera |
|
|
146
|
-
| `showControls` | Show/hide default camera controls |
|
|
70
|
+
`e.media` is a `Blob`. Assign it straight to an `ImageView`, or write it to a
|
|
71
|
+
file with `Ti.Filesystem`.
|
|
147
72
|
|
|
148
|
-
|
|
73
|
+
`saveToPhotoGallery` defaults to false, so a photo your app took exists only in
|
|
74
|
+
that blob until you save it somewhere. Write it to
|
|
75
|
+
`applicationDataDirectory` if it needs to outlive the screen.
|
|
149
76
|
|
|
150
|
-
|
|
151
|
-
- Success callback provides `event.media` (Blob)
|
|
152
|
-
- Note: `event.media` may only contain file info. Use `Ti.Filesystem.getFile(event.media.nativePath)` to access the actual file.
|
|
77
|
+
Close the camera with `Ti.Media.hideCamera()` when you dismiss it yourself.
|
|
153
78
|
|
|
154
|
-
|
|
155
|
-
On iPad, the photo gallery opens as a popover. Configure its position:
|
|
79
|
+
## The photo library
|
|
156
80
|
|
|
157
|
-
```
|
|
81
|
+
```js
|
|
158
82
|
Ti.Media.openPhotoGallery({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
success
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
### Memory management
|
|
166
|
-
Use `imageAsResized()` on blobs to avoid memory exhaustion. Resize to target dimensions before assigning to an ImageView.
|
|
167
|
-
|
|
168
|
-
```javascript
|
|
169
|
-
Ti.Media.showCamera({
|
|
170
|
-
success: (event) => {
|
|
171
|
-
const blob = event.media.imageAsResized(800, 600);
|
|
172
|
-
imageView.image = blob;
|
|
83
|
+
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
|
|
84
|
+
allowMultiple: false,
|
|
85
|
+
success(e) {
|
|
86
|
+
// Single selection returns a media Blob, whose length is bytes, not item count.
|
|
87
|
+
Ti.API.info('Picked one item');
|
|
173
88
|
},
|
|
174
|
-
cancel
|
|
175
|
-
error: (e) => { Ti.API.error(`Camera error: ${e.error}`); }
|
|
89
|
+
cancel() {}
|
|
176
90
|
});
|
|
177
91
|
```
|
|
178
92
|
|
|
179
|
-
|
|
93
|
+
With `allowMultiple: true` the success event carries an `images` array instead
|
|
94
|
+
of a single `media`, which is the shape change to handle rather than assume.
|
|
180
95
|
|
|
181
|
-
|
|
182
|
-
- Scaled to fit component dimensions by default
|
|
183
|
-
- iOS: use `backgroundLeftCap` and `backgroundTopCap` to control stretch regions
|
|
184
|
-
- Android: supports remote URLs as background images; iOS does not
|
|
96
|
+
## Audio
|
|
185
97
|
|
|
186
|
-
|
|
187
|
-
When using small images as backgrounds, iOS and Android stretch differently:
|
|
188
|
-
- `backgroundLeftCap` (iOS): pixels from the left that are not stretched. The middle section stretches.
|
|
189
|
-
- `backgroundTopCap` (iOS): pixels from the top that are not stretched.
|
|
190
|
-
- Android: supports remote URLs for background images; iOS does not.
|
|
98
|
+
Three objects, for three jobs.
|
|
191
99
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- `defaultImage`: local image to show while remote image loads
|
|
100
|
+
| Object | For |
|
|
101
|
+
| ------ | --- |
|
|
102
|
+
| `Ti.Media.Sound` | Short effects, held in memory |
|
|
103
|
+
| `Ti.Media.AudioPlayer` | Long files and streams |
|
|
104
|
+
| `Ti.Media.AudioRecorder` | Recording |
|
|
198
105
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
- `res-ldpi`, `res-mdpi`, `res-hdpi`, `res-xhdpi`, `res-xxhdpi`, `res-xxxhdpi`
|
|
106
|
+
```js
|
|
107
|
+
const sound = Ti.Media.createSound({ url: '/audio/tap.wav' });
|
|
108
|
+
sound.play();
|
|
203
109
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
- `foo~iphone.png` - iPhone-specific
|
|
209
|
-
- `foo~ipad.png` - iPad-specific
|
|
110
|
+
const player = Ti.Media.createAudioPlayer({ url: 'https://example.com/talk.mp3' });
|
|
111
|
+
player.addEventListener('change', (e) => Ti.API.info(e.description));
|
|
112
|
+
player.start();
|
|
113
|
+
```
|
|
210
114
|
|
|
211
|
-
|
|
115
|
+
`Sound` loads the whole file, so it is for something short. `AudioPlayer`
|
|
116
|
+
buffers, which is what you want for anything longer than a notification chime.
|
|
212
117
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const imageView = Ti.UI.createImageView({
|
|
217
|
-
image: url,
|
|
218
|
-
hires: true // Indicates high-resolution remote image
|
|
219
|
-
});
|
|
220
|
-
```
|
|
118
|
+
For audio that continues when the app is backgrounded, set
|
|
119
|
+
`Ti.Media.audioSessionCategory` and declare background audio in `tiapp.xml`.
|
|
120
|
+
On iOS configure both for background audio; these settings do not keep playback alive after process termination.
|
|
221
121
|
|
|
222
|
-
|
|
223
|
-
- Assign an array of images to `images`
|
|
224
|
-
- `duration`: milliseconds between frames
|
|
225
|
-
- `repeatCount`: 0 = infinite, >1 = specific count
|
|
122
|
+
## Video
|
|
226
123
|
|
|
227
|
-
```
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
124
|
+
```js
|
|
125
|
+
const video = Ti.Media.createVideoPlayer({
|
|
126
|
+
url: 'https://example.com/clip.mp4',
|
|
127
|
+
width: Ti.UI.FILL,
|
|
128
|
+
height: 240,
|
|
129
|
+
autoplay: true
|
|
130
|
+
});
|
|
131
|
+
win.add(video);
|
|
132
|
+
win.addEventListener('close', () => {
|
|
133
|
+
video.stop();
|
|
134
|
+
video.release();
|
|
236
135
|
});
|
|
237
|
-
// animationView.stop() / animationView.start() to control
|
|
238
136
|
```
|
|
239
137
|
|
|
240
|
-
|
|
138
|
+
A `VideoPlayer` is a view, so it lays out like any other and defaults to
|
|
139
|
+
filling its parent. Release it when the window closes: it holds a decoder, and
|
|
140
|
+
leaving it alive costs memory that the platform will eventually take back by
|
|
141
|
+
killing the app.
|
|
241
142
|
|
|
242
|
-
|
|
243
|
-
```xml
|
|
244
|
-
<ios>
|
|
245
|
-
<plist>
|
|
246
|
-
<dict>
|
|
247
|
-
<key>NSCameraUsageDescription</key>
|
|
248
|
-
<string>Need camera to take photos</string>
|
|
249
|
-
<key>NSPhotoLibraryUsageDescription</key>
|
|
250
|
-
<string>Need photo library access</string>
|
|
251
|
-
<key>NSMicrophoneUsageDescription</key>
|
|
252
|
-
<string>Need microphone for audio recording</string>
|
|
253
|
-
</dict>
|
|
254
|
-
</plist>
|
|
255
|
-
</ios>
|
|
256
|
-
```
|
|
143
|
+
## Next
|
|
257
144
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
<uses-permission android:name="android.permission.CAMERA"/>
|
|
263
|
-
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
264
|
-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
265
|
-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
266
|
-
</manifest>
|
|
267
|
-
</android>
|
|
268
|
-
```
|
|
145
|
+
[Location and maps](https://titaniumsdk.com/docs/build/location.md) covers the other capability that
|
|
146
|
+
needs asking first.
|
|
147
|
+
|
|
148
|
+
Contract corrections: [released Media API](https://github.com/tidev/titanium-sdk/blob/13_4_1_GA/apidoc/Titanium/Media/Media.yml), [VideoPlayer](https://github.com/tidev/titanium-sdk/blob/13_4_1_GA/apidoc/Titanium/Media/VideoPlayer.yml).
|