2017년 8월 9일 수요일

BUTTON PRESS FUNCTION


I was making a software in which i need a function like something called 'when button1.press' instead of 'when button1.click'. i was making it to send balues to arduino when i press button and send another value when i released it PL help me with the issue. ANY HELP WOULD BE HIGHLY APPRECIATED .

--
That sounds like you need to use the Button's TouchDown and TouchUp events.

-- 
Ok Thanks i will try it

--

App Inventor Classic


August 2015 Update
MIT App Inventor Classic is no longer available for building apps. You can continue to access old App Inventor Classic projects at the App Inventor Classic Web site. You can download them and you can use the converter as described above, but you cannot modify them or create new App Inventor Classic projects.
To work with App Inventor, use MIT App Inventor 2.

App Inventor Classic will shut down on July 15, 2015.
June 18, 2015 - The converter tool to transform MIT App Inventor Classic projects to MIT App Inventor 2 projects has just been released. It is carefully, and specifically designed to convert projects from the latest version of MIT App Inventor Classic to projects readable by MIT App Inventor 2 while maintaining the functionality, but necessarily not the same form of the projects. Make note, project files developed on other App Inventor systems may well not work with the converter tool and will not be supported by the MIT App Inventor team.

May 24, 2015 -- MIT App Inventor Classic will shut down on July 15, 2015. After July 15, 2015, you will not be able to access or edit your existing AI Classic projects. It will be impossible to create new AI Classic projects.

This shutdown applies only to AI Classic (AI1). App Inventor 2 (AI2) will not be affected.

The process of converting an AI1 project to an AI2 project has several steps. For each AI1 project you wish to convert to AI2, you will need to do the following (you can do the first two steps now):

1. Open your AI1 project in the most recent version of App Inventor Classic.
2. Download the AI1 project as an AI1 source file (.zip) to your computer.
3. Use the AI1 to AI2 conversion tool to convert the AI1 source file (.zip) to an AI2 source file (.aia).
4. Upload the converted AI2 source file (.aia) from your computer into App Inventor 2 as an AI2 project.

These steps are described in more detail in a separate document. You must perform the first two steps before the AI1 shutdown on July 15, 2015. We strongly recommend that AI Classic users begin to download their projects as .zip files now, so you will be ready to convert them when the converter becomes available.

Because of differences between AI1 and AI2, some difficulties may be encountered in the conversion process. It would be a good idea to try to convert important AI Classic projects well in advance of July 15, as soon as the converter becomes available, in order to have time to deal with these difficulties.

You might also want to make screenshots of the designer screen and the blocks, in case your project needs to be rebuilt in AI2, or the result of the conversion needs to be extensively modified. Keep in mind that AI Classic projects will not be accessible after July 15. Developers must make their own AI1 to AI2 projects conversions.

Google announced this week that the Files API on which AI Classic depends is being withdrawn in July. This makes it impossible to keep AI Classic running past then, and we regret the short notice for terminating AI Classic support. Many AI Classic developers were aware of the impending demise of AI Classic since about October 2014 and were urged in the forums to manually convert important projects at that time. We hope the conversion tool will simplify conversion for most developers.


Old App Inventor Projects


I am back to App Inventor world. :)

I saved many old projects I developed about 5 years ago. I would like to reopen them up for my reviews so I could continue my work with MIT App Inventor 2. The question is how to open them. 

--
welcome back!
you can convert the App Inventor Classic projects using the converter tool
for more information see here App Inventor Classic

--
Wow! Long time no see. :) You have been with App Inventor for all those years. That's great! My main interest is in Robotics and electronics. I am trying to use AI to control devices in the area of Internet of Things.

The link you mentioned is broken. Is there any other way to open old projects?

-- 
did you try the converter tool link http://convert.appinventor.mit.edu/ ?

-- 
No, I haven't tried the converter. I'll try that tomorrow. Thanks much.

AKA Kawacoder. (corrected)

-- 
I tried to convert my old projects (.zip) to App Inventor (.aia) but no luck. Too old. Sigh...

-- 
I now assigned this thread to Lyn, who wrote the converter tool... probably he can help you...

-- 
I have contacted Geo outside of this thread and offered my assistance with the conversion.

Thanks for the heads up, Taifun!

-- 

Exporting source to Android Studio


Is it possible for us to export the source code present in aia file into Android Studio? It will help us add many more extra functionalities coupled with the strength and easy programmability of  App Inventor 2. I am building an app for my college. 

--
No not possible,but search the forums for Java bridge. Or Google on Derek banas and app inventor. You Will find a simple tutorial how to make you're ai2 project in Android studio.

--

streaming video rtmp


hello good morning and have a doubt as to adapt transmission travez video streaming RTMP protocol to view the application if anyone has any idea appreciate your help and as I should

--
AI2 can`t direct play RTMP stream.
Few Android video player only can play RTMP stream, most of players can play RTSP stream.
For RTMP best one is MXPlayer, you can "declare/connect" MXPlayer with you app. That mean, send you RTMP links direct to MXPlayer only.

--

is it possible to stream an IP camera using app inventor 2


Im using App inventor on a college project and would like to add a live video stream to it.
is it possible to display an IP camera feed in the webviewer or otherwise?
I cannot find find anything useful to me  in other posts

--
This is it Bob search results for ip camera app     If what you want to do is not there then you might have to move to Eclipse or Android Studio.

--
Thanks, that will get me started

--

ip camera stream only in part off my screen


I get help from Taifun to get my stream running in my app

I can see now the cam with active starter...so thats working.

But it starts up the app vlc in full screen.

what i want is this...

I want to see my cam in the upper half of my screen. In the other half i want to put buttons for audio.. and start /stop exc....

So my screen and buttons have to stay avalible to use

I tried toe put the rtps url in web viewer but is not wotking.. see not url..

Url is working if i put it in my browser in Internet Explorer.

I als tried the video player is also not working...

How can i fix this?

I hope some one have a solusion. .

--
You probably can not use your camera the way you want. ActivityStarter, using your default browser is displaying the video. There is no way I am aware to make that work in a smaller window in AI2.

To do something like this, you may have to develop using Eclipse or Android Studio using Java (if you need a free compiler) or use one of the commercial Android compilers like Basic4Android ..not very expensive or others that are VERY expensive.

Using the WebVIewer is problematic in that it is NOT a full featured web browser.

Perhaps someone has a work around.   I do not think so.

--
thx for your fast answers..  was already afraid I wont work becours I could not find template ore tutorial about it..
I wil look at one of your surgestion..
and perhaps some one fixt this one way
is there in a way that I can split screen in AI2.. I mean like in IE that I have a navigation part and a active part?

--
What you can do is use effectively two screens.  The active part and the screen that pops up showing the video when ActivityStarter works; then what you 
could do is use the Device's back button (on the Android) to return to the active screen.

Something like:

will return the user to the 'controls' when pressing the BackButton  (assuming the controls are on Screen1, the main AI2 screen).

Can you split the screen in AI2 like in IE?   Yes, certainly, but only using the WebVIewer and apparently the WebViewer does not have the capability of viewing your camera video? What I would try would look something like this:

I am uncertain what url you would need.
That probably does not work, but it might?

--
if you use the activity starter, the other app does have the control and not the App Inventor app anymore, which means, the BackPressed event of the App Inventor app will not fire in this case.

Actually it is a very bad idea to open an already opened screen again like this
If  you do this several times, each time you create another instance of your app and your app is then open several times, which means, you also have to close your app several times. Also you easily can run out of memory.... so in short: don't do that!

is there in a way that I can split screen in AI2.. I mean like in IE that I have a navigation part and a active part?
 sorry, not possible!

--
@Gertjan     use this instead:

Taifun is correct, the other code MAY eventually cause problems, however it will return you to Screen1 .  Using the close screen should avoid memory issues and return you to Screen1, then when you call ActivityStarter again, you will create a new instance of the IP camera display which should work for you.

@Taifun .... the BackPressed   fires for me.

--
Screen1.BackPressed only can fire, if the App Inventor app has the control, see example app attached


--
@Taifun .... perhaps in the ActivityStarter instance you demonstrated, HOWEVER

This works when viewing a Web page .... so it appears some ActivityStarter activities do have an escape using BackPressed.

--
@SteveJG: try a notifier in the Screen1.BackPressed event and you will realize, that if you click the back button while the browser has the control, the notifier will not display anything. The back button in this case just closes the other app (the browser) and gives back the control to the App Inventor app (independent of your Screen1.BackPressed event). 

Only if the App Inventor app has the control, the Screen.BackPressed event will fire, which means in the example the notifier will display something...

--
@Taifun ...   who cares about Notifier ?   what happens after viewing a web page using ActivityStarater is you can return to app inventor's Screen1   I am not refering to your camera example ...which is a terrible example because the camera control is all messed up... does not work as it is supposed to. Some times you got to read..

--
@SteveJG: I used the notifier only as an example to demonstrate, when does the event Screen1.BackPressed fire...
and the answer is: Only if the App Inventor app has the control, the Screen.BackPressed event will fire
hope that helps ...

--

How to play (HTML5) Videos via Webviewer in AppInventor


I´ve just build an App, which shows a website. Now I wan´t to play some videos included in the Website via html5´s video tag, but everything I get is the sound from the video, but no pictures...

Is there any other way to implement the videos via Webviewer in appinventor 2? Im really thankful for every single helping line you write 2 me =)

--
the webviewer can't play videos
How to stream a video using the videoplayer component by  Hal and How to get the URL of a media stream
Advice: Before posting, it's a good idea to search in this forum. Many others have likely run into problems similar to yours. How to search see screenshot.
--
Thank you for your advice Taifun,

but please can we discuss this? Not possible is a static answer, I mean we have web 2.0 - there have to be a way how to run videos in app inventor´s webviewer... anyone know´s why it don´t run videos? Is AppInventor´s webviewer no flashfriendly? Or what´s the issue?

--
the webviewer is no full browser and therefore can't play videos

--
so will it be possible in the future to watch videos with appinventor´s webviewer?

--
probably yes, but I would not expect to get this functionality soon

--

Live video streaming on your website with Raspberry Pi Cam


Live video streaming on your website with Raspberry Pi Cam

Hello Raspberry Pi Community

We just realeased our open source project "Datarhei/Restreamer" on GitHub a few days ago. It is available under: https://datarhei.github.io/restreamer

The Datarhei/Restreamer allows free video streaming. The H.264 video is displayed via iFrame on the website. Even the video player is included. There is no streaming providers required and there are no monthly fees because your own internet connection is used for streaming. It can be streamed to external video services like YouTube Live, Ustream, Twitch or Livestream.com to use these services as a distributor for your video, too. Streamingservers like WOWZA or Adobe Media Server are supported. Our Docker image is easy to install and runs on Linux, MacOS and Windows. Datarhei/Restreamer can be perfectly combined with single-board computers like Raspberry Pi, Pi Zero and Odroid.

The elaborate installations and configuration of the needed programs to stream a camera, falls completely away with the Restreamer.  

Image

Main features:
1. H.264 Streaming
2. IP-Camera (RTSP/RTP), USB and Raspberry Pi Camera support
3. HLS Streaming for iOS and Android
4. HTML5 Open Source Video Player (Clappr)
5. iFrame code for embedding on website
6. Snapshot of running stream (adjustable interval)
7. External streaming to YouTube, Ustream, Livestream.com, Twitch or professional streaming server solutions of service providers (user account for used service required)
8. Easy installation with Docker for Linux 64bitWindowsOSXARMv6l (Pi 1/Linux), ARMv7l (Pi2 (Linux), Odroid U3 (Linux)
9. Datarhei/Restreamer ist free Software (licensed under Apache 2.0) and you can use it for any purpose, private or commercial

Comments:
1. Raspberry Pi camera and USB cams are not implemented in the UI yet, you have to activate them over a sweet and easy hack.
2. You are using your own internet connection for streaming your internet connection will overload with a large number of spectators. It depends on your video resolution, internetupload and the video motive you are streaming (water is not the same as still life). The Restreamer shows you the bandwidth of your camera. It helps to can calculate, at how much viewers your upload is no longer sufficient. Information about video compression can be found in our Wiki
3. The installation of Dockerfiles requires some time while a complete image is rolled out. Once this process is running, you can sit back and go drink a coffee. Depending on the CPU power of your computer, the process may take some time.
4. Please do not forget to forward port 8080 in your router, as described in the instructions to forward (port forwarding), if you want to use the iFrame code on your website.

If you notice errors or discrepancies, we are very grateful for constructive feedback. You are welcome to comment also feature requests for future versions of the Restreamer. The project is young, we ask for understanding if there are rough edges here and there. We work hard to fix things...

Everyone is very welcome to use the Webchat or our Forum for questions around the Restreamer on Google Groups. In our Wiki some questions about the technical aspects of Live Streaming are already answered. You can also make comments in this beautiful raspberrypi.org forum.

Thank you for your time and feedback. 

Friendly greets
The Datarhei Team
(Sven)

PS: If you like software development, can also forks on GitHub and start developing - Everyone is welcome, there is always something to do!
Stream me up, Scotty!
GitHub    ► https://datarhei.github.io/restreamer/
Twitter    ►https://www.twitter.com/datarhei 
Chat       ► https://chat.datarhei.org
Facebook ► https://www.facebook.com/datarhei/





Play http video stream in VideoPlayer component without waiting the end of download


I use MIT App Inventor 2 / Windows 7 / Chrome version Version 31.0.1650.63 m.
I'm trying to play http h264 video stream in VideoPlayer component. Ultimate goal : Remotely control from Android my raspberry pi robot mounted on RC car. (Gyro for direction / "Live" video stream from Raspicam.
1) Video is streamed from raspberry pi :
pi@raspy01 ~ $ raspivid -o - -t 0 -hf -w 320 -h 240 -fps 15|cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
2) I try to play the video stream in my Android App :
Set VideoPlayer1.Source to "http://1192.168.1.25:8080"
call VideoPlayer1.Start
Result : My App stops responding until... the end of streaming ! In fact, if I stop the streaming process on the raspberry, I can play the previously downloaded stream part in the VideoPlayer component !
So, I think, I hope, that if there's a way to start the player before waiting the end of file download, it will be a success !

--
Ooopsss... correction :
2) I try to play the video stream in my Android App :
Set VideoPlayer1.Source to "http://1192.168.1.25:8090"
call VideoPlayer1.Start


--
Try this. Put the play command in a clock Timer block set to 0 ms and initially disabled.
Then when ready to play the stream, enable the timer.
The first block in the timer should be to disable the timer.
the second block should set the source, the third to start the player.
May or may not work, but something to try anyway.

--

How to Create App Books by Appinventor?


I am new in App Inventor. What I was trying to make - an app which is just a BOOK which have lots of pages. Here is the outline i have. 

Page 1: Book Cover Page ( A link at a bottom to enter on the book). 

Page 2. Index

Page 3: The Book's content...it may go to several pages

Now my question is: 

How can i create Text Pages in Appinventor?
How do i connect all the pages from the Index pages? 
Do i have to add separate Screens for each of my Book page? 
How can I link the indexed and other pages of my book from the Cover Page? What is linking system of Inventor? 

Looking forward a complete suggestions. 

--
See below in BLUE.

I am new in App Inventor. What I was trying to make - an app which is just a BOOK which have lots of pages. Here is the outline i have. 

Page 1: Book Cover Page ( A link at a bottom to enter on the book). 

Page 2. Index

Page 3: The Book's content...it may go to several pages

Now my question is: 

How can i create Text Pages in Appinventor?
There are several ways... one is to read them into screens from text files embedded in the app, but if there are a lot of graphics and tons of text, you'll approach the AI 5MB limit.  The BEST way for you to do this is to do the book as an HTML page online, and read it into a web viewer or web component.  That way, there's no overhead in your app for the document.  If the HTML document is not TOO big, you could include it in the app as an asset and just load that into the web or webviewer components on startup.  If you use HTML, you can link all of your chapters and pages as any web page would and have that functionality in AI's components. 

How do i connect all the pages from the Index pages? See above
Do i have to add separate Screens for each of my Book page? NO!  If you use the web component, it would handle all of it in that one component.  If you read them in from text files, you just replace the text in a disabled Textbox, so you'd have the scrolling.
How can I link the indexed and other pages of my book from the Cover Page? What is linking system of Inventor? Again, see above!

Looking forward a complete suggestions. 

--
How to read a HTML page stored as asset inside of App Inventor 

--
I just put the entire book, Treasure Island by Robert L. Stevenson in a book using just text files.  All 37 Chapters!!!

I change chapters with buttons, but now that I know that the text blocks can take a LOT of text, I am going to build this with a ListPicker to change chapters.
A 'book' is doable this way.  Formatting for paragraphs is an issue which might be overcome by inserting  the \n character within the text to create line breaks 
between paragraphs.    I think I can do that using a text editor replacing the #10#13 s with \n s.

I hope to post something tomorrow.

What a neat idea.  Yes, you can use AI2 to write a 'book' app.   

--
Thank you very much. Some terms seem unknown to me. Lets solve these by using Google Search. Will let you guys know if i face any problem at near future. 

--
I have uploaded some html pages which is like frontpage.html. But when i will use the Call Webviewer1.GoToURL and URL: file//android_assets/frontpage.html...it couldn't loaded...and showing an error like the requested file was not found.  What would be the exact URL to placed upon there? I mean, If I place any html file on Media; then what the URL it will have that I can later use on Blocks. 

--
see again this link for the path to be used 
I have three ways to do the App Book.  You asked:

How can i create Text Pages in Appinventor?   

There are several ways.  Taifun's suggestion is a very good one.
You can load the book as a single html.  If you use a single html, going to specific chapters becomes an issue.
If you use a separate html for each chapter you can control the 'chapters' as Taifun controls the html pages or you
can use a ListPicker to request individual html files.

A different way, if your book is short might be to use.
Text blocks attached to Label controls.

LIke this:

The example used buttons to control chapters.  If I were developing the app for myself, I would use a ListPicker to change chapters.

I did not attempt to include an image for the cover.  I would use an image control, put the cover png in it, then  hide the control and use a button,
listpicker to show it when needed using the above method.    Using an html, you embed the image in the html.

How do i connect all the pages from the Index pages? 

Good question.  That depends on the method used to present the text.   Html or Labels with Text.
With html, you can use html coding.  Taifun's example demonstrates how.   You can also go directly to numerous html resources 
using a listpicker and the basic goto url page, each item pointing a different html chapter if each chapter is a separate html.

Or, using an html, you can control everything using html commands on the "Book Web Page" you create.

With text blocks, you would use either labeled buttons or a ListPicker to select the appropriate chapter global variable.

Do i have to add separate Screens for each of my Book page? 
No.   Either method will allow you to use a single screen. 

How can I link the indexed and other pages of my book from the Cover Page? 
Lots of ways to do this:   Buttons, ListPicker , html code in the CoverPage html.   I bet you can think of other ways.

Oh, the third way... a combination of the two mentioned.  AI2 is fairly flexible in dealing with text.

You may want to experiment a lot.  Have fun.

Hope this is helpful to you and others.

--
Did you omit the colon (:) from between "file" and "//" in your app too?
That might have been the cause of your problem.

--
Thanks Everyone for your time. Thank You. :)

--

How to convert string to int in processing


I am trying to make a hands free mouse using Arduino IDE and Processing IDE. I don't have a problem with serializing the code and converting to string, but when I try and convert the serial string into int the int goes to 0. I have tried to trim it and used integer.parseInt but it still gives me the error:
NumberFormatException : For input String:"".
Here is my code:
import processing.serial.*;
import java.awt.event.KeyListener;
import java.awt.Robot;

Serial myPort;  // Create object from Serial class
Robot robot;
String val;     // Data received from the serial port
boolean valtrue;
int xy = 0;
int x=0;

void setup()
{
    String portName = Serial.list()[3]; 
    myPort = new Serial(this, portName, 9600);
    myPort.bufferUntil('.');
    try { 
        robot = new Robot();
    } 
    catch (Exception e) {
        e.printStackTrace();
    }
}
void draw() {
    //reading serial port until \n
    String sensorValue = myPort.readStringUntil('\n');
    if (sensorValue != null) {
        int value = Integer.parseInt(sensorValue.trim());
        println(value);
    }
}
If anyone is able to help, please answer.

--
Processing has an int() function that you can use instead of Integer.parseInt(). Behind the scenes the int() function is calling the Integer.parseInt() function, but it's shorter. Up to you.
But your error says it all: you're passing an empty String value "" into the parseInt() function. An empty String value can't be turned into a number, so you get the exception.
You're going to have to track down why your String value is empty, but that's what's causing this particular error. I will point out that the draw() function is called 60 times per second, and you're trying to read from your port every single time, so maybe you're reading faster than you're writing?

--