a. Display still images as foreground and background graphics
b. Implement local and streaming audio playback
c. Implement local and streaming video playback
d. Capture still images and video from the camera
e. Retrieve images from the device’s photo gallery app
Validate
Implement Local Streaming audio playback
Implement Remote Streaming audio playback
Capture video from the camera
Validate
/*To validate above path check following
Prasads-MacBook-Pro:~ prasadkatankot$ adb shell
root@vbox86tp:/ # cd data/data
root@vbox86tp:/data/data # cd com.delhi/app_appdata
root@vbox86tp:/data/data/com.delhi/app_appdata # ls
Exercise - 1
Implement Local Streaming audio playback
Solution
function PlayLocalAudio(){
Ti.API.info(Ti.Filesystem.getResourcesDirectory());
//var mp3URL = Ti.Filesystem.getResourcesDirectory()+ 'music.mp3';
var textDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'FileManipulations');
if (textDir.exists()) {
var mp3URL = Ti.Filesystem.getFile(textDir.resolve(), 'magic.mp3');
}
//var mp3URL = Ti.Filesystem.getResourcesDirectory()+ 'music.mp3';
var audioPlayer = Ti.Media.createAudioPlayer({
url : mp3URL
});
audioPlayer.start();
}
Exercise - 2
Implement Remote Streaming audio playback
Solution
function PlayRemoteAudio(){
var audioStreamer = Ti.Media.createAudioPlayer({
url: 'http://www.tonycuffe.com/mp3/pipers%20hut.mp3'
});
audioStreamer.start();
}
Exercise - 3
Implement local video playback
Implement local video playback
Solution
function PlayLocalVideo(){
var textDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'FileManipulations');
if (textDir.exists()) {
var videoURL = Ti.Filesystem.getFile(textDir.resolve(), 'Nature.mp4');
var videoStreamer = Titanium.Media.createVideoPlayer({
url:videoURL,
autoPlay:true,
mediaControlStyle:Titanium.Media.VIDEO_CONTROL_EMBEDDED
});
$.indexWindow.add(videoStreamer);
}
Exercise - 4
Implement remote streaming video playback
Solution
function PlayRemoteVideo(){
var videoStreamer = Titanium.Media.createVideoPlayer({
url:'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
autoPlay:true,
mediaControlStyle:Titanium.Media.VIDEO_CONTROL_EMBEDDED
});
$.indexWindow.add(videoStreamer);
}
Exercise - 5
Capture video from the camera
Solution
exports.retrieveVideo=function(videoPlayer, win){
var intent = Titanium.Android.createIntent({
exports.retrieveVideo=function(videoPlayer, win){
var intent = Titanium.Android.createIntent({
action : Ti.Android.ACTION_PICK,
type : "video/*"
});
intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
win.activity.startActivityForResult(intent, function(e) {
if (e.resultCode == Ti.Android.RESULT_OK) {
if (e.intent.data != null) {
// If everything went OK, save a reference to the video URI
videoPlayer.visible=true;
videoPlayer.url=e.intent.data;
}
else {
Ti.API.error('Could not retrieve media URL!');
}
}
else if (e.resultCode == Ti.Android.RESULT_CANCELED) {
Ti.API.trace('User cancelled video capture session.');
}
else {
Ti.API.error('Could not record video!');
}
});
};
No comments:
Post a Comment