Situation
In my application I have a WebView which loads its data inside an IFrame from an url.
Code Snippet:
String url = www.myexampleurl.com/video1.html;
String data = "<IFRAME SRC=" + url + " FRAMEBORDER=0 ... />";
WebView.loadData(data, MIME_TYPE, ENCODING);
The website itself, loads his video into a flash player and I simply display this in the WebView. This works perfectly, with one nasty sidenote... Android has stopped supporting flash which means in the future my application will not work anymore by default. -Not acceptable!-
What I tried already
Solution to replace the flashplayer
I fetched the url of the video that is given to the flashplayer and I load it directly inside a VideoView or WebView with HTML5. These work solutions work! Perfect! But again a nasty sidenote.
The url (ex. www.myexampleurl.com/video1/video.mp4) is being generically created by the website (I think for each session). This means I don't have a consistent path to the video to load in my View. The advantage of my first approach with the flashplayer inside the Webview was that the flashplayer does all the work.
Solution to get the correct video-url
No serious problem yet, because I can tackle this problem too. I can do some PHP/DOM-scripting which would scrape the website for the video-url and give it back to my application. This way I always have the generic url and my video can be loaded inside my View. Again that works! And again.. there is a sidenote..
I can not go directly to my website that has the flashplayer. The flow can be as followed:
Enter www.myexampleurl.com/video1.html
Get the message: Wait 5 seconds
Click continue
Video is starting to play inside the flashplayer.
The problem is that I get my video url only after step 3.
Question
Is there a way to solve my getting-the-generic-url problem? Or a better approach to play the video?
-- Is it bad, very bad or extremely bad practice to continue to support flash in Android? I can also just provide the flashplayer .apk and let users install it..
Thanks, hope someone can help me :)!
Don't do drugs. Don't do flash.
Get the file up on a server you have control of so you can give a proper path. If that is not an option, you'll have an app that can brake any moment the owner of the website decides to change something with the path.
Is parsing www.myexampleurl.com/video1.html the only way to fecth the url you want?
Maybe you can do the PHP/dom stuff in the client instead of in your server: use an invisible WebView to load www.myexampleurl.com/video1.html and try to get the url from it.
WebViewClient::onLoadResource(WebView view, String url) may be helpful (I am not sure). This task must be achievable by hacking WebView, the problem is how complicated it will be.
Related
I'm working on e-shop project and I need to handle URL. I never worked with URL like that. I can't post URL there, because of the private data that are included in. But it is URL that is not going open a tab in browser, because it automatically download a file(in chrome) and in firefox it only ask to download. No tab opened. I did some research, but I didnt find any URL handling like this.
Here a edited example of how the URL looks:
https://domain.cz/api/export?token=121212121212121212
It is some kind of API, but my question is: How I can handle this type of URL in PHP? I want to save that file or even better - get the file contents directly to variable in code.
Thanks for you help
Confused developer
I have searched about that for very long time. But I havn't known how it works and how to create it. I am so serious to get it. I am a beginner of Ajax and JQuery. I wish to create a fixed mp3 music player in my web. Although I have some code and know how to do mp3 player for html5, but I have not knew how to do fixed mp3 player which won't change playing when another pages load. Could you help me, please. Example: it is like of www.revernation.com and facebook's chat popup box, still active without refreshing another pages.
You can't keep an mp3 player running when the user navigates to a completely different site in the same browser window.
You can however keep the current page open and fake navigation to other subpages of your own site with History API + AJAX and DOM manipulation. The trick is sometimes called pjax.
An example implementation: https://github.com/defunkt/jquery-pjax
Angular.js does what is described in the previous answer.
What you need to do is convert your app into an SPA.
Single-Page Applications (SPAs) are Web apps that load a single HTML
page and dynamically update that page as the user interacts with the
app. SPAs use AJAX and HTML5 to create fluid and responsive Web apps,
without constant page reloads. However, this means much of the work
happens on the client side, in JavaScript.
Best for SPA
i suggest you to go with AngularJS.
You can still do it with JQuery with Ajax calls if you don't want to use other front-end frameworks
We're a website completely written in PHP, we use facebook metatags since we provide facebook sharing, liking, etc...
problem is when we share a link from our site to facebook, it shows the picture correctly, however trying to reshare the same link from another user, removes the picture and shows the link only.
Further troubleshooting using the FB debug tool shows below error message:
Unable to download og:image: The image referenced by the url of og:image tag could not be downloaded.
The weird thing is that the image is already see and accessible in the debugger!!
A sample page:
http://fbcomics.com/home/index/92/date/1462
Debugger for it:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Ffbcomics.com%2Fhome%2Findex%2F92%2Fdate%2F1462
Your cooperation is highly appreciated.
I think that you probably need to urlencode() the url value going into the content attribute of your og:image meta tag.
This might be related to a recent Facebook bug. https://developers.facebook.com/bugs/239522122851150
Issue was solved by itself. It seems that Facebook needs sometime (weeks I think) to store the page information including the picture using its crawlers.
If you face this, most probably you'll need to wait for sometime before sharing your new pages.
Thanks,
I run ads on my site which are usually YouTube videos. I would like to find out if a user clicked these videos. I'm basically trying to use this data in a statistics plugin that I'm creating.
I've tried searching many different keywords but I can't really find anything.
I would appreciate it if I could be pointed in the right direction. Any ideas, hints or links are welcomed.
As you mention YouTube I doubt you have control over the URL.
But, if you can control the URL embedded in the video, then I would suggest building a simple redirect script on your server. Make sure the URL contains either the redirect URL or a code representing the URL which would be held in your Data Base. Add a logging function to the redirect script and hey presto.
If you have no control over the URL, then off the top of my head maybe you could implement some client side JS to add an overlay to the video which becomes the click-able element and implement the URL redirect script above. Some methods to get the URL from the video: https://www.google.com/search?q=jquery+youtube+URL
Anyone know a good external link tracking script ? IE. to catch links and referrer stats through a posted img tag, even if there's no actual IMG. I know how PHP works in this matter, but I'd hate to code it from scratch.
You can get the referrer via the built-in $_SERVER['HTTP_REFERER'] variable. So use that in the php page that your link/image refers to. Then just have some code on that same php page to stick it where you need it via insertion to a database, or whatever other method you prefer.
Just a note: If you create the image file with php, don’t waste your users bandwidth and return a 204 status code (no content) instead of a real image.
With Google Analytics you automatically get referrer information, visitor locations, pageviews, and much more. That's probably much easier than coding your own solution. If Google isn't your cup of tea, there are plenty of other solutions.
Add some special setup and you can track outbound links from your own pages as well.