i want to play youtube video in Titanium webview but it cannot play video .the link is http://www.chicagowolves.com/news?format=feed&type=rss .and this link works in mac browser
and the error is
[ERROR] : Error loading: , Error: Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x78fbe6b0 {NSErrorFailingURLKey=https://www.youtube.com/v/IKGPgnram1E?version=3&f=user_uploads&app=youtube_gdata, NSErrorFailingURLStringKey=https://www.youtube.com/v/IKGPgnram1E?version=3&
f=user_uploads&app=youtube_gdata, NSLocalizedDescription=Frame load interrupted}
function WebView(data) {
var self = Ti.UI.createWindow({
backgroundColor : 'white',
title : 'Videos',
height : Ti.UI.FILL,
width : Ti.UI.FILL
});
var webview = Titanium.UI.createWebView({
url : data,
height : Ti.UI.FILL,
width : Ti.UI.FILL,
backgroundColor : 'green'
});
self.add(webview);
return self;
}
module.exports = WebView;
Try this code:
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: 'http://www.youtube.com/embed/' + myVideoID + '?autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0',
enableZoomControls: false,
scalesPageToFit: false,
scrollsToTop: false,
showScrollbars: false
});
win.add(webView);
win.open();
I tried it before, it works fine, it's copied from this link.
Related
I'm having problems trying to record audio into a file. I'm trying to run the sample code (with the required permissions in the tiapp.xml) but i'm always getting errors (like "+[NSBlock boundBridge:withKrollObject:]: unrecognized selector sent to class 0x1b5549500"; at the stop() action).
I can't find a module for audio recording (i've used the tutorial.audiorecord but it doesn't work in newest versions of SDK)
This is the sample code from the appcelerator documentation page https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.AudioRecorder
I try everything but doesn't work.
Someone have a working example or a module for Appcelerator SDK 7?
var window = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var recordStart = Ti.UI.createButton({
title: 'Start',
top: 10
});
var recordPause = Ti.UI.createButton({
title: 'Pause',
top: 60
});
var recordStop = Ti.UI.createButton({
title: 'Stop',
top: 110
});
var recordPlay = Ti.UI.createButton({
title: 'Play',
top: 160
});
var audioRecorder = Ti.Media.createAudioRecorder();
var record;
var audioPlayer;
window.addEventListener('open', function(e) {
if (!Ti.Media.hasAudioRecorderPermissions()) {
Ti.Media.requestAudioRecorderPermissions(function(e) {
if (e.success) {
window.add(recordStart);
}
});
} else {
window.add(recordStart);
}
});
recordStart.addEventListener('click', function(e) {
audioRecorder.start();
});
recordPause.addEventListener('click', function(e) {
if (audioRecorder.getPaused()) {
recordPause.setTitle('Pause');
audioRecorder.resume();
} else {
recordPause.setTitle('Resume');
audioRecorder.pause();
}
});
recordStop.addEventListener('click', function(e) {
record = audioRecorder.stop();
Ti.API.info(record.getNativePath());
});
recordPlay.addEventListener('click', function(e) {
audioPlayer = Ti.Media.createAudioPlayer({
url: record.getNativePath()
});
audioPlayer.start();
});
window.add(recordPause);
window.add(recordStop);
window.add(recordPlay);
window.open();
Thanks in advance
This is an example using Titanium's Hyperloop: https://gist.github.com/dinahgarcia/119ac00c91334d3951601cf347bad8d4
To be able to use it you need to enable Hyperloop: https://docs.appcelerator.com/platform/latest/#!/guide/Enabling_Hyperloop
i have created tab group with single tab and window for tab , i have set background image for tab window, image is showing properly on android but in iPhone i cant see any image any solution to this problem?
var tabGroup = Titanium.UI.createTabGroup({
navBarHidden: true,
layout: 'vertical'
});
Ti.UI.Clipboard.setText('');
var db = require('dbhelper');
db.callDb();
var windowTitle = Ti.UI.createLabel({
color: '#fff',
text: 'IEMR LITE'
});
var win1 = Titanium.UI.createWindow({
backgroundColor: '#fff'
});
if (Ti.Platform.name === 'iPhone OS') {
win1.titleControl = windowTitle;
win1.barImage = 'images/actionbar3.png';
win1.hideTabBar();
} else {}
win1.backgroundImage = 'images/default_portrait.png';
I have tried this code and its works for me. also make sure you are providing correct image path.
var tabGroup = Titanium.UI.createTabGroup({
navBarHidden : true,
layout : 'vertical'
});
Ti.UI.Clipboard.setText('');
//var db = require('dbhelper');
//db.callDb();
var windowTitle = Ti.UI.createLabel({
color : '#fff',
text : 'IEMR LITE'
});
var win1 = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
if (Ti.Platform.name === 'iPhone OS') {
win1.titleControl = windowTitle;
win1.barImage = '1.png';
win1.hideTabBar();
} else { }
win1.backgroundImage = '2.png';
var tab1 =Ti.UI.createTab({
window : win1
});
tabGroup.addTab(tab1);
tabGroup.open();
Try deleting your build folder and building for iPhone again. Sometimes after adding an image (or other binary resource), it doesn't get linked to the underlying built project properly until you do a clean build.
I am migrating a current project to 3.1.3 . I need a close button on the modal window so i had to use a NavigationWindow as suggested in the IOS7 migration guide. Here is what i have
btnSubscription.addEventListener('click', function(e) {
Ti.API.info('Subscription Button Clicked.');
openWindow("paymentsubscription.js", "Subscription");
});
function openWindow(url, title) {
var win = Ti.UI.createWindow({
url : url,
backgroundColor : 'white',
modal : true,
title : title
});
if (Titanium.Platform.osname !== "android") {
var winNav = Ti.UI.iOS.createNavigationWindow({
modal: true,
window: win
});
}
if (Titanium.Platform.osname !== "android") {
winNav.open();
}
else {
win.open();
}
}
Now on paymenttransaction.js i was previously doing this when i was using titanium 2.x
var mainWindow = Ti.UI.currentWindow;
var mainWinClose = Ti.UI.createButton({
style : Ti.UI.iPhone.SystemButtonStyle.DONE,
title : 'close'
});
if (Titanium.Platform.osname !== "android") {
mainWinClose.addEventListener('click', function() {"use strict";
mainWindow.close();
});
responseWindow.setRightNavButton(responseWinRightNavButton);
mainWindow.setRightNavButton(mainWinClose);
}
The problem i am facing is that i need to close winNav in the case of IOS and not win anymore. In paymenttransaction.js i was previously using
var mainWindow = Ti.UI.currentWindow;
But now i need to close the navigation window(winNav) and this does not hold good anymore. Is there anyway to do this? . Is there a Ti.UI.currentWindow equivalent for NavigationWindow ?
You aren't using the navigationWindow properly. You shouldn't be calling open() on a window when you use one.
You are looking for:
`winNav.openWindow(yourWindow)
Also when you are creating a new window, pass a pointer to your navigationWindow in the constructor, then you can close the window properly. Don't create a window like that use CommonJS's require() to return your window:
paymenttransaction.js:
function paymentTransactionWindow(navGroup, otherArgs) {
var mainWinClose = Ti.UI.createButton({
style : Ti.UI.iPhone.SystemButtonStyle.DONE,
title : 'close'
});
var win = Ti.UI.createWindow({
url : url,
backgroundColor : 'white',
modal : true,
title : title,
rightNavButton: mainWinClose
});
if (Titanium.Platform.osname !== "android") {
mainWinClose.addEventListener('click', function() {
navGroup.closeWindow(win);
});
return win;
}
module.exports = paymentTransactionWindow;
Then in your previousWindow:
PaymentTransactionWindow = require('/paymentTransactionWindow); //the filename minus .js
var paymentTransactionWindow = new PaymentTransactionWindow(winNav, null);
mainNav.openWindow(paymentTransactionWindow);
watch some of the videos on commonJS: http://www.appcelerator.com/blog/2011/08/forging-titanium-episode-1-commonjs-modules/
I am trying to place a back button at centre of window. I am able to achieve the same using image view. However navigation to previous windows except for the very last are failing.
Lets say I have traversed three windows A->B->C. From window 'C' the button takes me to window 'B'. But from window 'B' click of same button evokes no response (ideally it should have taken me to window 'A')
The code I have used are as following
{
var imgView = Ti.UI.createImageView({
top:'50%',
left : 0,
image : "icons/back.png"
});
imgView.addEventListener('click', function(){
self.close();
});
}
Add the above line in your each file which containing the new window, since you're opening new windows using url method.
var currentWindow = Ti.UI.currentWindow;
Then close the window as follows
imgView.addEventListener('click', function(){
currentWindow.close();
});
This will close the current window, since currentWindow represents the active window
I'll add the working Example :
app.js
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
var back = Ti.UI.createButton({
title : 'To win1 ',
width : '70%'
});
back.addEventListener('click', function(){
var win1 = Ti.UI.createWindow({
url : 'win1.js',
backgroundColor : 'white',
layout : 'vertical'
});
win1.open();
});
win.add(back);
win.open();
win1.js
var self = Ti.UI.currentWindow;
var back = Ti.UI.createButton({
title : 'Back to home',
top : 20,
width : '70%'
});
var next = Ti.UI.createButton({
title : 'To win2',
top : 20,
width : '70%'
});
self.add(back);
self.add(next);
back.addEventListener('click',function(){
self.close();
});
next.addEventListener('click', function(){
var win2 = Ti.UI.createWindow({
url : 'win2.js',
backgroundColor : 'white',
layout : 'vertical'
});
win2.open();
});
win2.js
var self = Ti.UI.currentWindow;
var back = Ti.UI.createButton({
title : 'Back to win1',
top : 20,
width : '70%'
});
self.add(back);
back.addEventListener('click',function(){
self.close();
});
i am new to Titanium and i am have 2 seemingly simple problems while trying to use it for the Android.
1) i am trying to navigate to the next page on click of a button. but instead it is showing me a blank black screen. i know my second page CreateNewMeetup.js is correct because i tried displaying it as the landing page of my app and it works. my codes are as follows:-
ApplicationWindow.js
...
var button = Ti.UI.createButton({
height:44,
width:'auto',
title:'Create New Meetup',
top:20
});
self.add(button);
button.addEventListener('click', function() {
var newWindow = Ti.UI.createWindow({
url : "/ui/common/CreateNewMeetupWindow.js",
fullscreen: false
});
newWindow.open();
});
return self;
CreateNewMeetupWindow.js
//CreateNewMeetUpView Component Constructor
function CreateNewMeetupWindow() {
var self = Ti.UI.createWindow({
layout : 'vertical',
backgroundColor:'white'
});
var contactsField = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color : '#336699',
width : 400,
height : 60
});
self.add(contactsField);
var locationField = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color : '#336699',
width : 400,
height : 60
});
self.add(locationField);
var lblNotifyMe = Ti.UI.createLabel({
color : 'black',
text : 'Notify me when s/he is',
textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
width : 'auto',
height : 'auto'
});
self.add(lblNotifyMe);
var btnGo = Ti.UI.createButton({
title : 'Go',
height : 'auto',
width : 100
});
btnGo.addEventListener('click', function() {
// Check console
Ti.API.info('User clicked the button ');
});
self.add(btnGo);
return self;
};
2) after installing the app onto my device, i tried to launch it. the app shows momentarily (about 3 seconds maybe) and then it shuts down by itself. i guess its an app crash? but it works well on the emulator.
Titanium experts please help :$
You can use the following methods in your program to navigate between windows
Method 1
//Your app.js file
var button = Ti.UI.createButton({
height:44,
width:'auto',
title:'Create New Meetup',
top:20
});
self.add(button);
button.addEventListener('click', function() {
//By doing this you're opening a new window
var newWindow = Ti.UI.createWindow({
url : "ui/common/CreateNewMeetupWindow.js",//Provide the correct path here
fullscreen: false
});
newWindow.open();
});
//Your CreateNewMeetupWindow.js file
var newWindow = Ti.UI.currentWindow;
var contactsField = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color : '#336699',
width : 400,
height : 60
});
newWindow.add(contactsField);
//You can add other controls here just like I added the contactsField
Method 2
var button = Ti.UI.createButton({
height:44,
width:'auto',
title:'Create New Meetup',
top:20
});
self.add(button);
button.addEventListener('click', function() {
var window = require('/ui/common/CreateNewMeetupWindow');
var newWindow = new window();
newWindow.open();
});
//Your CreateNewMeetupWindow.js file
function CreateNewMeetupWindow() {
var self = Ti.UI.createWindow({
layout : 'vertical',
backgroundColor:'white'
});
var contactsField = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color : '#336699',
width : 400,
height : 60
});
self.add(contactsField);
//Add other controls here
return self;
}
module.exports = CreateNewMeetupWindow;
You can use any single method from above. Do not mix the methods together.
You can use the following link for references
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-url
http://docs.appcelerator.com/titanium/latest/#!/api/Global-method-require
For your first problem, you are using the url property with a CommonJS object. So instead instantiate your window like this:
var newWindow = require("/ui/common/CreateNewMeetupWindow");
newWindow.open();
You would use the url property if your CreateNewMeetupWindow.js was not a CommonJS module.
Not sure what your second problem is, check your device logs and crash reports, otherwise there is no way to know what is going on.