2014년 12월 9일 화요일

how to import/parse text into my app from an other website


i'm making a radio app, all the basics are working now, only i want to see what track is playing when i'm listening to stream.

I did some reading, it is possible, only i don't understand it. I did see some examples about parsing text, only can't find it any more, forgot to save the page and still did not understand how to use the blocks. I cloud reproduce something when i see how to, but it is difficult for me to fill in de dots .

on our webpage Freeminded FM i have an url where i can find the stream info.

http://www.freemindedfm.nl/stream/info.html

this is how the info looks:  31126718|1|1|0|Online|AutoDJ|Kevin Holdeen - Dancing Days Podcast 89     i underlinded the part that i whant to use

    <head></head>
    <body>

        31126718|1|1|0|Online|AutoDJ|Kevin Holdeen - Danci…

    </body>

</html>

How can i get this info into my app. Can somebody give me some pointers, i would really appreciate this.

--
Perhaps use the split at first  text   at block


where |AutoDJ|Kevin Holdeen - Danci…

    </body>


|AutoDJ| is the at   puzzle piece      and    trim  where |AutoDJ|Kevin Holdeen - Danci…

    </body>    is the text

The do a DoIt and view the result.   That coding will get you part of what you need, then you need to manipulate the resulting text using the other Text control options.

Try some stuff.

--


hey Steve, thanks, well my first problem was how to get the info from http://www.freemindedfm.nl/stream/info.html  into my app , don't know what blocks to use, that is my first problem and the second how to get the last piece of text, but i can make an extra webpage where only the track info is shown. So it;'s more about how do i get text into my app from another url.  i want the track info to get on the Now playing info in the picture when i press play, so how do i get it there, i know it's a lot to aks.

--
Set to html page only text what you need (Artist - Song name)

Sample aia in attachment.


--
Whoohhh  :-) thats very nice, that works :-) Thank you, does that also work when i use an image, so you can aslo see the cover art in an other label.

--
Yes you can use Web->GotText also with image. But fist you need correct you image file names in server! 
That mean please remove all spaces because Android not correct it for you.
Browser change spaces to %20 but android NOT!

--
Ok, i will  look into that en make a page on my site with the correct url's, thanks for all the help. 

--
Hello Peep,

i used your example app with a image:   http://www.freemindedfm.nl/covers/livedjs/rjmusic.jpg  only i did not get the image into the app, it looks like in the picture.


--
you do not have to download that image, just assign the URL to the image source like this





--
Text can`t be as image :)
Fist insert Image in designer panel and the set Image PictureTo.
Something like this:

--

The image1.source block, does this exist in app inventor beta 2  (can't find it)  or is this as Peep prants explained in his picture , now i sued peep prants example, but does it mean that i donwload the picture every time and does it cost more mb fort users. 

--

It almost works now :-)   only the track title updates but the cover does not update when a new track is playing, the code looks like in the picture, i tried some stuff out, but can't get them both to update.  Any suggestions. 

--
Please move: "Set Image2-Picture to http://www.freemindedfm.nl/app/current_cover.jpg" block to Clock1 Timer :)

--
i was sure i allready tried this solution, butt i just did it again and it works :-)  Crazy .




i used a different solution, that also worked, but i think your solution is better, ore do you know if this solution usses less resources


One more question.  Is there also a possibilty then when i start up the app that the cover and track title load directly, so you see it directly and not have to wait 10 seconds and after that is done the timer takes over and checks for updates.  

--
Of course :)
Set to screen Init. ->WebGet and set image.

--
really happy with this, works perfectly.  

I tested this app on a few phones ( galaxy 3, 4 and htc one and one plus) and noticed that samsung phone load the stream much quicker in 1 or 2 seconds and htc phones in about 5 till 8 seconds.  So people keep pushing the play button and then it will not function correctly

When you use a text butten for play it turns to orange when you press it and changes back to grey when the stream is active, so you can see that its doing something, like opening the stream.  When i use an image that feature is not working. Is it possible to also let the picture change like when you use a text button or let people see it is loading. 

--
Yes, music loading time depend what is network speed and what network (WiFi ) chip is used in phone. 
My LG phones loading faster then Sony Z series.
Use some logic:)
Some advice:
1. Remove Exit and pause button, it not needed. "back" press usually exit and stream cant be paused.
2. You can also load stream when screen init. then user not need to press "Play" and it hidden when music playing.
3. You can set only one button visible when app play music ) sample i send you by e-mail.

One my sample music app, for song info I use webView component, then I can send some messages to screen or use moving gif files :)


--
Thanks,  i tested it with the same high speed network, all high end mobile phones, don't know the network chip, butt they are different in the phones.

i will look into your tips/file and work on it. i will show you the result. 

--
your example works great

--

I tested your example, only when i am browsing to my phone and go back to my app it starts up a seconden Stream, not all the time butt sometimes, looks Like a bug or something

--
Please select "PlayOnlyInForeground"
Double start is issue only in development mode. If you build app and try install apk in phone it`s play OK in foreground (also stop music when call come in).

--
Thank you

--

Hello, still having some issues with my app, in general it works fine on 3G network and on home wifi networks, only on some office wifi networks i'm having trouble with my cover.  When the app starts the timer works and does an automatic update. I have 2 timers 1 for the cover and 1 for the track title. on 3g and normal wifi networks it updates perfectly. Only on the office (work) wifi the cover will not update.  The tracktitle does update. so very strange, also happens when i use 1 timer and activate both. i enabled the timer in properties, so not with a block. I also  used a webviewer for the cover instead, only then the tracktitle would not update. This problem is specific for the office wifi and could be a cahce feature of the wifi network. Does anybody know a workaround for this problem. A got a tip  the make the url variable like /current_cover.jpg?74272457 only really don't know how to make app inventor do that :-)

--
I think this problem is wifi network firewall settings or this wifi network use proxy for tracking and logging user statistic and not like refresh same content. That mean if you image file is all time same name, then it`s stored in proxy cache and show all time same picture.

--
Yes, that is the problem, so i tried it out with the webviewer for the cover and it looks like it is working, only it does not work as smoothly, when you startup the app you see the cover form last time and it takes 10 secondes before it updates even with screen initialize. So Mabye i will make a webpage with al of the info in one and then use the webviewer to show it so everything works at the same time. I will keep you posted when it is done


--
@ peep prants Hi can u contact me for a job plz?diez.dieci@gmail.com, I need some informations about your prices so i can tell you more.. ty

--
Still can't get the app bug free. 

I use a play button to start up the stream, when i press play the play button its hidden and the stop button appears, works good, only when i'm palying the stream and then do other stuff on my phone or i get called and go back to the app the play button appears, only the stream is still running so i should see the stop button. 
So then it is not possible to stop the stream, only by stopping the app with backpress only then i see screen 1 again and can't get out.   So how do i fix the problem with play and stop button, any ideas, i used the example that you showed me. 

--
You can completely remove Play/Stop buttons, and set Back Press to Stop Audio or Exit App.



Use you imagination :)

--

:-)  yes, that's also a good option, only then i will get the same problem with the stream instead of with the button.  Sometimes you will get 2 streams playing, because of the screen initialize function that kicks in and i set my phone back to original settings   ,so no debugging or developer options on my phone and still having does issues. I think that my first version will be an app with a play and stop button so i don't encounter these problems. Thanks for your help.  I will check out your example and see if i have those problems in your app, maybe it's something wiith my phone or android version.  EDIT: i checked out your app, that won't have that problem :-)

--
I acquainted with double stream problem only in development mode. When you app is installed to phone, then it`s must be OK.

--



댓글 없음:

댓글 쓰기