flashlight animation

8 posts, 0 answers
  1. huseyin celik
    huseyin celik avatar
    25 posts
    Member since:
    Aug 2012

    Posted 04 Apr 2015 Link to this post

      Hi

    i want to make animation with flashlight plugin.

    I want to open flashlight and close and again open and open again and then i want to close

    so i try to call

    switchon();

    switchoff();

    switchon();

    switchon();

    switchon();

    switchon();

    switchoff();

    switchoff();

    switchoff();

    but it give error  

     

    and then i use setInterval

     but it still give error 

     

    in admin panel admin will insert open or close info in array  then i will process that command 

     

     

  2. huseyin celik
    huseyin celik avatar
    25 posts
    Member since:
    Aug 2012

    Posted 04 Apr 2015 in reply to huseyin celik Link to this post

    i have an array like this

    array []=[1,1,1,0,0,0,0,0,1,1,1,0,0]

    so i will handle flashlight via that array

    if array item is 0 i will switchoff

    if array item value is 1 i will SwitchOn

    how can i do this?

  3. huseyin celik
    huseyin celik avatar
    25 posts
    Member since:
    Aug 2012

    Posted 07 Apr 2015 in reply to huseyin celik Link to this post

    i tried this

    but for does not work with window.plugins.flashlight

    what is problem with this?

    i control parameteres everything is ok 

     

    var on = [ true, false ];

     function flashlightDemo()

    { for(i=0;i<on.length;i++)

    {

      if (on[i])

    {

            window.plugins.flashlight.switchOn(); 

      }

    else

           window.plugins.flashlight.switchOff();

            }}}

  4. Martin Yankov
    Admin
    Martin Yankov avatar
    177 posts

    Posted 08 Apr 2015 Link to this post

    Hello,

    I have just tried the code from your last post in the Flashlight plugin demo and I think it works as expected. Keep in mind that this plugin will only work on an actual device that has a flash light.

    I have attached the modified demo project for reference. Here is the code I added in scripts/demo.js:
    switchOnOffArray: function () {
        var on = [ true, false, true, false, true, false ];
        for(i=0;i<on.length;i++) {
              if (on[i]) {
                    window.plugins.flashlight.switchOn();
              }
                else
                {
                   window.plugins.flashlight.switchOff();
                }
        
    },

    And in index.html I added one more button:
    <button data-role="button" class="button" data-bind="click: switchOnOffArray">Switch ON/Off From Array</button>

    Deploy the project on your device, go to the Demo tab and tap the Switch On/Off From Array button. The flashlight should flash 3 times.

    The only difference is that I added some more true and false values for 3 flashes. Try the attached project and let me know if it works on your side. I have tested this on Android Nexus 5 with Android 5.1.

    Regards,
    Martin Yankov
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  5. huseyin celik
    huseyin celik avatar
    25 posts
    Member since:
    Aug 2012

    Posted 08 Apr 2015 in reply to Martin Yankov Link to this post

    you just move

    that array (var on = [ true, false, true, false, true, false ];) from outside function to inside function

    now it works .thank you

     

    i want to load that array(on array) from database

    so i will make ajax call

    should i make ajax call inside that function?are there any sample that contains ajax call?

     

    i  want to make animation with many device

    for example i want to make animation at 22:00 hours

    so every device  have different time 

    what should i do?

    should i use server time?i want to start al device flash on on same time and off at same time 

    synchrony is very important for me 

  6. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 13 Apr 2015 Link to this post

    Hi Hüseyin,

    It isn't possible so synchronize devices by making AJAX calls, as these calls can take different periods of times on different devices, based on internet speed, device capabilities, etc. 

    As a development tool, AppBuilder cannot offer a way to implement your requirement. You would need to further research how to sync devices system time or how to get two devices to communicate with a minimum lag.

    You may need to implement a custom plugin of your own to wrap this functionality from a native implementation. Some discussions on the topic of syncing device time are available here:

    Sync Android devices via GPS time?

    How can I get the “network” time, (from the “Automatic” setting called “Use network-provided values”), NOT the time on the phone?

    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  7. huseyin celik
    huseyin celik avatar
    25 posts
    Member since:
    Aug 2012

    Posted 15 Apr 2015 in reply to Tsvetina Link to this post

    hi

    i do my own way 

     for example if administrator want to animation start at 20:30 with on= [true,false,true,true,false....] array

    i check if time is 20:30 if yes i start it for first item(on[0])

    and then i check time again if time is 20:30+X(difference two action time)

     

    if time is ok then i process it for seconde item(on[1])

     

    this algoritm good looks but when i call switch on or off function it does not work  

     

     

     

     

     

    http://www.telerik.com/forums/flashlight-animation-synchronize-problem

  8. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 17 Apr 2015 Link to this post

    Hello Hüseyin,

    I just replied in your other forum thread. Please check the reply there.

    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top