Tuesday, April 10, 2012

Phonegap Android Webview Video plays only audio

I've started to play around with phonegab today. When I was trying to capture video its working fine. Now I wanna show the captured video in the webview. so I was trying as below.



var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
videoString = "<video width='320' height='240' controls='controls'><source src="+path+" type='video/mp4' /> <source src="+path+" type='video/ogg' /> <source src="+path+" type='video/webm' />Your browser does not support the video tag.</video>";
$('#myVideo').html(videoString);
}


};

// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};

// start video capture
function takeVideo(){
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1});
}


but in the UI I see the player being appended but it plays only the audio not the video.. wot could be the problem.??



Any help appreciated and thanks for your time in advance.





javascript how to open a exe on server

im adding some functionality´s on me site and i would like to open some exe´s i have made using vb2010 ,the exe will me on my local server but the site will be hosted in a server some were in the world .



to execute the exe i just need to add boton on the site whit the path to the location of the file on my server? like



  C:\folder\folder\myfile.exe


or there other more easy way to do this ?



thnx for any help





Can't search for all generated terms in lucene index

I'm indexing and searching code using a custom analyzer. Given text "will wi-fi work", following tokens are generated ('will' being a stop-word, is eliminated).



wi-fi {position:2 start:5 end:10}
wifi {position:2 start:5 end:10}
wi {position:2 start:5 end:7}
fi {position:2 start:8 end:10}
work {position:3 start:11 end:15}


When I search for terms wi-fi, work I get search results. However, when I issue any query (phrase/non-phrase) for wifi, wi, fi I don't get any results. Is there anything wrong with the generated tokens?



Parsed search queries:



For wi-fi (works fine)



Lucene's: +matchAllDocs:true +(alltext:wi-fi alltext:wifi alltext:wi alltext:fi)


For wifi (no results returned)



Lucene's: +matchAllDocs:true +alltext:wifi


For "will wi-fi work" (works fine)



Lucene's: +matchAllDocs:true +alltext:"(wi-fi wifi wi fi) work"


For "will wifi work" (no results returned)



Lucene's: +matchAllDocs:true +alltext:"? wifi work"




returning multiple values in web service

I am designing a web-service using java and eclipse which returns the user details who are marked as customer in the database



I was successfully able to return details for a single user (as there was only one entry in the dB) with the following code:



public class GetData {

public LoginDetails getDetails(){
Connection conn;
Statement stmt;
ResultSet rs;

try {
LoginDetails lds=new LoginDetails();
Class.forName(driver);
conn=DriverManager.getConnection(url,username,password);
stmt=conn.createStatement();
String sql="select * from login where usertype='customer'";
rs=stmt.executeQuery(sql);
while(rs.next()){
lds.setUsername(rs.getString(1));
lds.setPassword(rs.getString(2));
lds.setUsertype(rs.getString(3));
lds.setActive(rs.getString(4));

}
return lds;
}
catch(ClassNotFoundException c){
c.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}

return null;
}


}



What should I do if there are multiple values in dB matching the criteria and I want to display them all. Please advice.





Calling a variable from another method

i'm quite new in eclipse and having a problems with calling variables from other methods,such as:



    btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {

final JFileChooser fc = new JFileChooser();
int returnVal = fc.showDialog(fc, null);

if (returnVal == JFileChooser.APPROVE_OPTION) {
File prnfile = new File(fc.getSelectedFile().toString());

}

}

});
btnNewButton.setBounds(54, 164, 89, 23);
frame.getContentPane().add(btnNewButton);

JButton btnNewButton_1 = new JButton("print");
btnNewButton_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {


File file = new File(prnfile);
int ch;
StringBuffer strContent = new StringBuffer("");
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
while ((ch = fin.read()) != -1)
strContent.append((char) ch);
fin.close();
} catch (Exception e1) {
System.out.println(e);
}



});
btnNewButton_1.setBounds(257, 164, 89, 23


Now,how can i call "prnfile" from the other method?Normally i would create a public object in c# but it doesnt work in Eclipse,so i dunno where to go (being a complete noob :) )





How to integrate log-in credential

Thanks for previous replies,



i am doing mobile application with user log-in, i am maintaining separate database to handle the user log-in details. i want to integrate the facebook and twitter user log-in into my application.(ie) if user having facebook or twitter id, if they use that id to access my application it should be accessible.for example in our stack overflow log in we having different log-in category(facebook,Google). Can anyone guide me how to do this in our own application. I very much eager to learn this kind of knowledge, if i made anything wrong pls let me know.





iOS sending parameter to selector using NSTimers

Is there a way to send a parameter to the selector via a NSTimer ?



myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:) userInfo:nil repeats:NO];

- (void)removeTheNote:(NSString*)note
{
NSLog(@"Note %@ ----------- REMOVED!",note);
}


I know that using :



myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:myNote) userInfo:nil repeats:NO];


doesn't work, so I am asking, is there a way to do this?





C application error on run

I've built a C application, and when I build it, it shows no errors, but when I run it, it gives me the error "Segmentation Fault: 11".
If it helps, here is the code I am using:



#include <stdio.h>
int main(char *argv[]) {
printf("The project path is: ./Projects/%c", argv[1]);
return 0;
}




failing to display array entered from keyboard in c

I'm new to c and I'm trying to write a c program that get 10 integer values entered from keyboard using scanf and then print them using printf but the result is not correct. Here is the code:



   #include<stdio.h>
#include<conio.h>
main(){
int x[10];
printf("\n\n\t\t PRGRAM THAT CAPTURES AND PRINTS 10 SCORES");
for(int i=1;i<=10;i++){
printf("\n\tEnter Score %d", i);
scanf("%d",x);
}
printf("\n\t The entered scores are: %d",x[i]);
return(0);
}


the output given is a four digit number like 8731 yet I expect something like 1234567890. some help please





Create custom view for Spotify playlist

I'm trying to create a custom view for a spotify playlist. right now I create a playlist view in my app using the following:



var playlist = models.Playlist.fromURI(myPlaylist);
var playerView = new views.Player();
playerView.track = playlist.get(0);
playerView.context = playlist;
var cover = playlist.get(0).data.album.cover;
$('#grid').append(playerView.node);


The default spotify playlist view has the album compilation for the art, and clicking on the playlist also provides direct access to the playlist. I'd like to change this so that I can set the playlist art to the cover variable above (or other custom image), and restrict the hyperink so that it doesn't access the playlist but only initiates play/pause.



I tried to edit the node innerHTML directly but then the playlist doesn't actually begin playing either. Is there an easy way to either edit the default spotify view or is there available sample code for creating a custom view?





Sonar Java Web Client: Authors by line null

When running the following code on my Sonar, measure returns null. (Should return something on the lines of "1=author;2=author..."). However it works on nemo.sonarsource.org.



Other measures eg: violation work correctly on mine so this is probably not a question of faulty code. I suspect I need to configure Sonar somehow?



    private final Sonar sonar;

public String getAuthors(String resourceKey){
return getMeasure(resourceKey, "authors_by_line").getData();
}

private Measure getMeasure(String resourceKey, String measureName){
Resource resource = sonar.find(ResourceQuery.createForMetrics(
resourceKey, measureName));

Measure measure = resource.getMeasure(measureName);

return measure;
}




Focus does not run inside iframe on seperate domain

I have an iframe that calls focus() on one of the <input> fields inside of its own frame when the page loads.



For some reason when this iframe is shown on the page with a seperate domain, the focus does not seem to work.



It looks like a cross-domain issue as this works if the iframe is on the same domain, but I don't know why.



The focus is being called inside of the iframe, it's not trying to interact with anything outside of the iframe and nothing is trying to get inside.



Any ideas?





Getting Started with PHP Extension-Development

Please suggest help articles or tutorials about PHP "low" level ?-modules programming interface.





How to call powershell function properly?

I wrote a function to convert the input month parameter to a certain format. such as if I passed 04 to the funtion and the function will return the "_APR_". the function I wrote is like below:



function GetEnMonth()
{
param([string] $month)
switch ($month)
{
($_ -eq "01"){$result = "_JAN_"}
($_ -eq "02"){$result = "_FEB_"}
($_ -eq "03"){$result = "_MAR_"}
($_ -eq "04"){$result = "_APR_"}
($_ -eq "05"){$result = "_MAY_"}
($_ -eq "06"){$result = "_JUN_"}
($_ -eq "07"){$result = "_JUL_"}
($_ -eq "08"){$result = "_AUG_"}
($_ -eq "09"){$result = "_SEP_"}
($_ -eq "10"){$result = "_OCT_"}
($_ -eq "11"){$result = "_NOV_"}
($_ -eq "12"){$result = "_DEC_"}
default {$result ="_No_Result_"}
}
return [string]$result;
}


Then I use below command to excute the function to get the result:



$mYear = $today.substring(0,4) 
$mMonth =$today.substring(4,2)
$mDate = $today.substring(6,2)
$monthInEn = GetEnMonth $mMonth


well, the result is always "_No_Result_", why? below is the exception:



 **** Exception type : System.Management.Automation.RuntimeException
**** Exception message : You cannot call a method on a null-valued expression.


Could anyone give me an answer for this? thx.
I have searched goole a lot but don't find useful solutions.





NSMutableString and (character)-encoding issue: getting \U00fc in case of ü

i am fetching my entity from coreData and saving the result of fetchrequest to an NSMutableString for text to speech.



self.ttsInboxCards = [[NSMutableString alloc] initWithString:@""];  
[self.ttsInboxCards appendString:[[entitySetsCards valueForKey:@"cardTitle"] description]];


And in NSLog i am getting this values:



F\U00fcr | schl\U00e4ge | zuh\U00f6ren  


which should be:



Für | schläge | zuhören  


I have tried a lot of things to get the correct encoding, for example with:



stringWithUTF8String:  


and so on, but nothing worked.



How can i prevent this issue?





jquery resize on div element

jquery has the resize()-event, but it just work with window.



jQuery(window).resize(function(){/*What ever*/});


This works fine!
But when i want to add the event to a div element it doesnt work.



E.g.



jQuery('div').resize(function()/*What ever*/{});


I want to start an callback when the size of a div-element has changed. I DONT want to start a resizeable-event - just a event to check if the size of a div-element has changed.



Is there any solution to do this ?





Export SQL Server database to script using a command

I need to export my database into a script file using a SQL command.



I'm using MS SQL Server 2010 Express.



Is it possible and if yes whats the command?





Android:TextToSpeech Not Working

Hi i create one application which is depend on TextToSpeech. When i am trying to run my

application It show the NullPointerException in Logcat. i search lot but didn't find helpful Answer.Here Check my Code on this link and Here is my logcat.



04-10 15:11:37.872: WARN/System.err(2798): java.lang.NullPointerException
04-10 15:11:37.872: WARN/System.err(2798): at com.example.examguide.ExamAppearingActivity.onCreate(ExamAppearingActivity.java:80)
04-10 15:11:37.872: WARN/System.err(2798): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-10 15:11:37.882: WARN/System.err(2798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-10 15:11:37.882: WARN/System.err(2798): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-10 15:11:37.882: WARN/System.err(2798): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-10 15:11:37.882: WARN/System.err(2798): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-10 15:11:37.882: WARN/System.err(2798): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:11:37.882: WARN/System.err(2798): at android.os.Looper.loop(Looper.java:123)
04-10 15:11:37.882: WARN/System.err(2798): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-10 15:11:37.882: WARN/System.err(2798): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:11:37.892: WARN/System.err(2798): at java.lang.reflect.Method.invoke(Method.java:507)
04-10 15:11:37.892: WARN/System.err(2798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-10 15:11:37.892: WARN/System.err(2798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-10 15:11:37.892: WARN/System.err(2798): at dalvik.system.NativeStart.main(Native Method)


Any help is Appreciated...





How do you allocate memory at a predetermined location?

How do i allocate memory using new at a fixed location? My book says to do this:



char *buf=new char[sizeof(sample)];
sample *p=new(buf)sample(10,20);


Here new is allocating memory at buf's address, and (10,20) are values being passed. But what is sample? is it an address or a data type?





filtering input text wiht jquery

i want to filtering and locking a input text . for example in some input when user type persian/farsi charachters cant type english or when user type english cant type persian.
means some input only accepet persian/farsi characters and some other accept english.
thanks.
also i find this http://www.thimbleopensource.com/tutorials-snippets/jquery-plugin-filter-text-input

if know any regular experssion for persian characters can help me.
or how can change the keyboard mode.