@maccesar/titools 2.0.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/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Media APIs
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Media APIs](#media-apis)
|
|
6
|
+
- [Table of Contents](#table-of-contents)
|
|
7
|
+
- [1. Audio APIs](#1-audio-apis)
|
|
8
|
+
- [Playing Basic Sounds (Ti.Media.Sound)](#playing-basic-sounds-timediasound)
|
|
9
|
+
- [Streaming Audio (Ti.Media.AudioPlayer)](#streaming-audio-timediaaudioplayer)
|
|
10
|
+
- [Recording Audio (Ti.Media.AudioRecorder)](#recording-audio-timediaaudiorecorder)
|
|
11
|
+
- [2. Video APIs (Ti.Media.VideoPlayer)](#2-video-apis-timediavideoplayer)
|
|
12
|
+
- [Cross-Platform Considerations](#cross-platform-considerations)
|
|
13
|
+
- [Basic Usage](#basic-usage)
|
|
14
|
+
- [Key Events](#key-events)
|
|
15
|
+
- [3. Camera and Photo Gallery APIs](#3-camera-and-photo-gallery-apis)
|
|
16
|
+
- [Camera (Ti.Media.showCamera)](#camera-timediashowcamera)
|
|
17
|
+
- [Gallery (Ti.Media.openPhotoGallery)](#gallery-timediaopenphotogallery)
|
|
18
|
+
- [Memory Management](#memory-management)
|
|
19
|
+
- [4. Images and ImageView APIs](#4-images-and-imageview-apis)
|
|
20
|
+
- [Background Images](#background-images)
|
|
21
|
+
- [ImageView Component](#imageview-component)
|
|
22
|
+
- [Density-Specific Images](#density-specific-images)
|
|
23
|
+
- [Flipbook Animations](#flipbook-animations)
|
|
24
|
+
- [Permissions Checklist](#permissions-checklist)
|
|
25
|
+
- [iOS (tiapp.xml)](#ios-tiappxml)
|
|
26
|
+
- [Android (tiapp.xml)](#android-tiappxml)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 1. Audio APIs
|
|
31
|
+
|
|
32
|
+
### Playing Basic Sounds (Ti.Media.Sound)
|
|
33
|
+
- Use for short sound effects, beeps, ambient audio
|
|
34
|
+
- **Entire file loads into memory** - use `preload=true` to reduce delay
|
|
35
|
+
- Methods: `play()`, `pause()`, `stop()`, `setVolume()`
|
|
36
|
+
- Property `allowBackground=true` for continued playback when app closes
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
const sound = Ti.Media.createSound({
|
|
40
|
+
url: 'beep.mp3',
|
|
41
|
+
preload: true
|
|
42
|
+
});
|
|
43
|
+
sound.play();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Streaming Audio (Ti.Media.AudioPlayer)
|
|
47
|
+
- Use for streaming from web URLs (MP3, HTML Live Streaming)
|
|
48
|
+
- Supports pseudo-streaming and HLS
|
|
49
|
+
- Handle interruptions (phone calls) with app-level events:
|
|
50
|
+
- `pause` event: Call `setPaused(true)` or `pause()`
|
|
51
|
+
- `resume` event: Call `setPaused(false)` or `start()`
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const streamer = Ti.Media.createAudioPlayer({ url: 'https://example.com/stream.mp3' });
|
|
55
|
+
streamer.start();
|
|
56
|
+
|
|
57
|
+
Ti.App.addEventListener('pause', () => { streamer.setPaused(true); });
|
|
58
|
+
Ti.App.addEventListener('resume', () => { streamer.setPaused(false); });
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Recording Audio (Ti.Media.AudioRecorder)
|
|
62
|
+
- Requires microphone permission
|
|
63
|
+
- Properties:
|
|
64
|
+
- `compression`: `Ti.Media.AUDIO_FORMAT_ULAW` (low-fi) or `AUDIO_FORMAT_LINEAR_PCM` (hi-fi)
|
|
65
|
+
- `format`: `Ti.Media.AUDIO_FILEFORMAT_WAVE`
|
|
66
|
+
- Methods: `start()`, `pause()`/`resume()`, `stop()`
|
|
67
|
+
|
|
68
|
+
## 2. Video APIs (Ti.Media.VideoPlayer)
|
|
69
|
+
|
|
70
|
+
### Cross-Platform Considerations
|
|
71
|
+
- **Android**: Must be fullscreen (Intent-based, not a view proxy)
|
|
72
|
+
- **iOS**: Can be embedded or fullscreen; set `height`/`width` for embedded
|
|
73
|
+
|
|
74
|
+
### Basic Usage
|
|
75
|
+
- `url` property: Local file path or remote URL
|
|
76
|
+
- `autoplay=true`: Auto-start when rendered
|
|
77
|
+
- `movieControlStyle`: `Ti.Media.VIDEO_CONTROL_EMBEDDED` for embedded controls
|
|
78
|
+
- `scalingMode`: Control fill/fit behavior
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const player = Ti.Media.createVideoPlayer({
|
|
82
|
+
url: 'movie.mp4',
|
|
83
|
+
movieControlStyle: Ti.Media.VIDEO_CONTROL_EMBEDDED,
|
|
84
|
+
autoplay: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// iOS only: add to window
|
|
88
|
+
if (Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'ipad') {
|
|
89
|
+
win.add(player);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Stop when window closes
|
|
93
|
+
win.addEventListener('close', () => { player.stop(); });
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Key Events
|
|
97
|
+
- `complete`: Playback ended (check `e.reason` vs `Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED`)
|
|
98
|
+
- `load`: Movie finished loading
|
|
99
|
+
- `fullscreen`: Entered/exited fullscreen (check `e.entering`)
|
|
100
|
+
|
|
101
|
+
## 3. Camera and Photo Gallery APIs
|
|
102
|
+
|
|
103
|
+
### Camera (Ti.Media.showCamera)
|
|
104
|
+
- Requires camera permission and usage descriptions
|
|
105
|
+
- Success callback provides `event.media` (blob)
|
|
106
|
+
- Use `saveToPhotoGallery: true` to automatically save
|
|
107
|
+
- Handle `cancel` and `error` callbacks
|
|
108
|
+
|
|
109
|
+
### Gallery (Ti.Media.openPhotoGallery)
|
|
110
|
+
- Success callback provides `event.media` (blob)
|
|
111
|
+
- Note: `event.media` may contain only file info, use `Ti.Filesystem.getFile(event.media.nativePath)` to access actual file
|
|
112
|
+
|
|
113
|
+
### Memory Management
|
|
114
|
+
- **Critical**: Use `imageAsResized()` on blobs to avoid memory exhaustion
|
|
115
|
+
- For display: Resize to target dimensions before assigning to ImageView
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
Ti.Media.showCamera({
|
|
119
|
+
success: (event) => {
|
|
120
|
+
const blob = event.media.imageAsResized(800, 600);
|
|
121
|
+
imageView.image = blob;
|
|
122
|
+
},
|
|
123
|
+
cancel: () => { Ti.API.info('Camera canceled'); },
|
|
124
|
+
error: (e) => { Ti.API.error(`Camera error: ${e.error}`); }
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 4. Images and ImageView APIs
|
|
129
|
+
|
|
130
|
+
### Background Images
|
|
131
|
+
- Scaled to fit component dimensions by default
|
|
132
|
+
- **iOS**: Use `backgroundLeftCap` and `backgroundTopCap` to control stretch regions
|
|
133
|
+
- **Android**: Supports remote URLs as background images; iOS does not
|
|
134
|
+
|
|
135
|
+
### ImageView Component
|
|
136
|
+
- `image` property accepts: URL, local path, or Ti.Filesystem.File object
|
|
137
|
+
- Scaling behavior:
|
|
138
|
+
- Both `height` AND `width` specified: Unproportional scale (aspect ratio NOT maintained)
|
|
139
|
+
- Only ONE dimension specified: Proportional scale (aspect ratio maintained)
|
|
140
|
+
- `defaultImage`: Local image to show while remote image loads
|
|
141
|
+
|
|
142
|
+
### Density-Specific Images
|
|
143
|
+
|
|
144
|
+
**Android**: Place in resolution-specific directories:
|
|
145
|
+
- `res-ldpi`, `res-mdpi`, `res-hdpi`, `res-xhdpi`, `res-xxhdpi`, `res-xxxhdpi`
|
|
146
|
+
|
|
147
|
+
**iOS**: Use naming convention:
|
|
148
|
+
- `foo.png` - Non-retina
|
|
149
|
+
- `foo@2x.png` - Retina
|
|
150
|
+
- `foo@3x.png` - iPhone 6 Plus
|
|
151
|
+
- `foo~iphone.png` - iPhone-specific
|
|
152
|
+
- `foo~ipad.png` - iPad-specific
|
|
153
|
+
|
|
154
|
+
For remote density-specific images on iOS:
|
|
155
|
+
```javascript
|
|
156
|
+
const density = Ti.Platform.displayCaps.logicalDensityFactor;
|
|
157
|
+
const url = `https://example.com/image@${density}x.png`;
|
|
158
|
+
const imageView = Ti.UI.createImageView({
|
|
159
|
+
image: url,
|
|
160
|
+
hires: true // Indicates high-resolution remote image
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Flipbook Animations
|
|
165
|
+
- Assign array of images to `images` property
|
|
166
|
+
- `duration`: Milliseconds between frames
|
|
167
|
+
- `repeatCount`: 0 = infinite, >1 = specific count
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
const frames = [];
|
|
171
|
+
for (let i = 1; i < 18; i++) {
|
|
172
|
+
frames.push(`frame${i}.png`);
|
|
173
|
+
}
|
|
174
|
+
const animationView = Ti.UI.createImageView({
|
|
175
|
+
images: frames,
|
|
176
|
+
duration: 100,
|
|
177
|
+
repeatCount: 0
|
|
178
|
+
});
|
|
179
|
+
// animationView.stop() / animationView.start() para controlar
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Permissions Checklist
|
|
183
|
+
|
|
184
|
+
### iOS (tiapp.xml)
|
|
185
|
+
```xml
|
|
186
|
+
<ios>
|
|
187
|
+
<plist>
|
|
188
|
+
<dict>
|
|
189
|
+
<key>NSCameraUsageDescription</key>
|
|
190
|
+
<string>Need camera to take photos</string>
|
|
191
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
192
|
+
<string>Need photo library access</string>
|
|
193
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
194
|
+
<string>Need microphone for audio recording</string>
|
|
195
|
+
</dict>
|
|
196
|
+
</plist>
|
|
197
|
+
</ios>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Android (tiapp.xml)
|
|
201
|
+
```xml
|
|
202
|
+
<android>
|
|
203
|
+
<manifest>
|
|
204
|
+
<uses-permission android:name="android.permission.CAMERA"/>
|
|
205
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
206
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
207
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
208
|
+
</manifest>
|
|
209
|
+
</android>
|
|
210
|
+
```
|