I want to implement video-cast of video from internal storage or sd-card.
I see that this sample (https://github.com/googlecast/CastVideos-android ) does cast of internet content only.
How can I do same thing but using video from device ??
There is some tutorial or sample code ?
Edit:
I do more search, local web server is the way ? Something like nanohttpd ?
Yes, you need to set up a local web server in your android app and serve the media from that server.
step 1:
Run simple http server app in your device
https://play.google.com/store/apps/details?id=jp.ubi.common.http.server&hl=en
step 2: open chrome in your laptop and type your android device's http address (from the above app). you will get your device's directory. copy the address of a video file.
step 3. in CastVideos-android project open VideoProvider.java file.
modify the line :
String videoUrl =
step4: run the CastVideos-android project and enjoy casting.
(try clicking on big buck bunny video, to get the video casted faster)
Related
I have created an Android app that has the purpose to promote my country all over the world., using Intel XDk ( using HTML 5 and JavaScript ). You can download the app from here 1
Every time I start the app with the device connected to the internet, it says
Application Error The connection to the server was unsuccessful (file:///android_asset/www/index.html), but when I turn off the Internet it works. Some features require Internet connection, so I really need to connect the device to internet.
The only on-line plugin that I use is a speech to text plugin downloaded from here 2. Can somebody help me solve this problem?
Alex Hang
file:///android_asset/www/index.html
Is a pointer to the local assets directory within the package of your application. Instead of trying to connect to is just use loadDataWithBaseURL and then point it to your assets. The issue with this is that it is a local copy of the html page, so it changes occur you have to update the file in the assets directory.
WebView article = (WebView) findViewById(R.id.article_webview);
article.loadDataWithBaseURL("file:///android_asset/www/index.html", null, "text/html", "UTF-8", null );
i want to have a URL like this one (https://www.ooklnet.com/files/381/381489/video.mp4) where when you click it and itll play the video. Thing is this isnt my website or video. i tried my URL which i thought was corrct (http://54.XXX.XXX.238/srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4) and it gives me this error:
The requested URL /srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4 was not found on this server.
I know for a fact that theres a video in the file path on my server. Proof:
(I need this URL for my android app so i can display the video in the app.)
How can i create a link like this one (https://www.ooklnet.com/files/381/381489/video.mp4)?
I have a Ubuntu 14.04.4 server with AWS EC2!
Any help would be appreciated!!
Thank you!
1) your EC2 has to have security groups open to allow any access to port 80 from the Internet
2) your EC2 has to be running some web server software such as apache
3) apache needs to be configured to serve files, check the document root
4) apache needs to be configured to correctly send mp4 with the right mime type headers see this answer Apache not serving .mp4 files correctly - shows the contents of the file rather than a download prompt
If it is apache ( and not nginx or another web server) you are using check the access log file /var/log/apache2/access.log and the default error log /var/log/apache2/error.log
Im working on an app (flex 4.12 sdk, using flashbuilder 4.5, creating an app for ios and android, testing on an android htc one primarily)... and am using the camera to capture a file... Im then saving that image to the application storage directory, and I want to open the image in the default web browser or trigger a native dialog (android users) to choose the web browser of their choice... how it opens isnt really important right now -- Im mainly trying to just 'access' it with the device and 'load' it outside my air app...
heres the code I have:
var fs2 : FileStream = new FileStream();
fs2.addEventListener(Event.CLOSE, fileCompleteHandler);
var targetFile : File = File.applicationStorageDirectory.resolvePath("test.jpg");
fs2.openAsync(targetFile, FileMode.WRITE);
fs2.writeBytes(myBMDByteArray,0,myBMDByteArray.length);
fs2.close();
and for the event listener that detects the close of the newly created file:
function fileCompleteHandler(e:Event):void {
trace('File saved.');
trace('exists? ' + targetFile.exists);
trace('the url: ' + targetFile.url);
trace('path: ' + targetFile.nativePath);
navigateToURL(new URLRequest(targetFile.url));
}
I get the following info back from this listener
File saved.
exists? true
the url: app-storage:/test.jpg
path: /data/data/air.com.xxxxx.apptesting.debug/com.xxxxx.apptesting.debug/Local Store/test.jpg
... and problem is that navigateToURL cant access the location where the file is stored (the protocol shows in browser as file:///data/data/air.com/xxx... )
how can I use navigateToURL to get access to this newly created file in the web browser or whatever native application the device associates with the file (its a .JPG file)? I also have had success in adding the newly created image to the camera roll but couldnt figure out how to then open that newly saved image in the native camera roll or whatever app the device chooses or presents to the user for the .jpg format.
I can show the user the image INSIDE my app by referencing the bitmap data fine, I just want to give the user access to the physical file that Im creating on their device.
I even have had success in posting (via urlLoader) the bitmap data as base64 encoding and then creating a file on the server side and loading that url but the encoding and trip to and from the server to give the user the image adds a lot of overhead and it takes a little too long and I'd like to avoid that elongated process.
Thanks for any help anyone can provide - let me know if I need to be more specific in any of this.
Solved the issue... I was able to store / write my file in the documentsDirectory using:
var targetFile : File = File.documentsDirectory.resolvePath('test.jpg');
and then
navigateToURL(new URLRequest(targetFile.url));
And this works fine now. Hopefully it helps someone else! Seems that the storage directory SHOULD work but up until now I've only written to and read files stored there... maybe to open the files one HAS to copy it to a 'safe' location in the filesystem (i.e. sd card?)... will move on to test in ios Now - hope all works well in that OS. Thanks all who chimed in on this.
My first hunch is that you need to specify the proper user-permissions in your application descriptor so you can use the openWith functionality with content from your application.
Remember that you need to specify this for IOS and Android specifically.
On your application.xml you need this permissions set inside android > manifestAdditions > manifest:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
With this permissions you can save files to applicationStorageDirectory:
const FILE_LOADER:URLLoader = new URLLoader();
FILE_LOADER.addEventListener(Event.COMPLETE, onTempFileComplete);
FILE_LOADER.dataFormat = URLLoaderDataFormat.BINARY;
FILE_LOADER.load(new URLRequest(BASE_URL + filePath));
The applicationStorageDirectory can only be accessed by the application it belongs too when using Android or iOS. navigateToURL() hands over your request to the default browser, which cannot access said directory.
documentsDirectory is a public directory in Android, but not in iOS. So it cannot be used for both platforms. Unfortunately none of the pre-compiled file paths File has point to a public directory in iOS. You can find a table explaining all the pre-compiled paths here
I am currently building an Android app using HTML5. Inside my app, I am providing link to a HTML file available inside tomcat server on my machine.
<div>Beep</div>
The HTML file "sample.html" has link to download a file in same file location, where the sample.html is placed.
sample.html has this --> Click to download
The problem here is, when I run my app on an android mobile, the link stays dumb and it won't initiate the download from the given path.
But, the same URL when I open in a web browser, the download starts.
Could anyone let me know why this URL is not initiating the download inside my app??
I already enabled "Allow installation of non-Market applications" in the settings of my android device.
If you are using real device you must set your url with static ip of your machine like 192.168.0.10 and in emulator 10.0.0.2
See this post.
Use 10.0.2.2 as IP for server running on the same machine as the Android emulator.
Check out following post with similar problem:
Download File inside WebView
Check out this link for setting up the mime type in tomcat.
Copied for reference:
In Tomcat 5.x and 4.x, the default mappings between MIME types and file extensions are stored in the file tomcat_home/conf/web.xml, where tomcat_home is the path under which Tomcat was installed on your server. The mappings specified there are applied to all web / WAP applications hosted on your Tomcat server. Application-specific mappings should be set in the WEB-INF/web.xml file under the directory of your web / WAP application.
Each mapping is specified with the <mime-mapping>, <extension> and <mime-type> tags. Here is an example:
<web-app>
...
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/vnd.wap.xhtml+xml</mime-type> </mime-mapping>
<mime-mapping>
<extension>wml</extension>
<mime-type>text/vnd.wap.wml</mime-type> </mime-mapping>
<mime-mapping>
<extension>wmls</extension>
<mime-type>text/vnd.wap.wmlscript</mime-type> </mime-mapping>
<mime-mapping>
<extension>wbmp</extension>
<mime-type>image/vnd.wap.wbmp</mime-type> </mime-mapping>
...
</web-app>
I just started a project with phonegap and I m getting a "invalid url error" message box + app crash on a html link to "http://maps.google.fr" (external link) , It works without problem on IPhone..
any ideas why?
The latest code has the new white-list feature. If you are referencing external hosts, you will have to add the host in PhoneGap.plist under the "ExternalHosts" key. Wildcards are ok. So if you are connecting to "http://phonegap.com", you have to add "phonegap.com" to the list (or use the wildcard "*.phonegap.com" which will match subdomains as well).