Saturday, May 17, 2014

Embed ISS Live video in WebView

Now you can view Live HD video from ISS (International Space Station) from UStream. And we can embed it in WebView. (Link to runnable APK at bottom of this post)




Create /assets/isslive.html
<html>
<head>
<meta name = "viewport" content = "width = device-width, height = device-height" />

<style>
iframe {
 width: 100%;
 height: 100%;
}
</style>

</head>
<body>

<iframe src="http://www.ustream.tv/embed/17074538?wmode=direct" 
 style="border: 0 none transparent;" 
 frameborder="no"></iframe><br />

</body>
</html>

/res/layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.androidiss.MainActivity" >
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:autoLink="web"
        android:text="http://android-er.blogspot.com/"
        android:textStyle="bold" />

    <WebView
        android:id="@+id/mybrowser"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

</LinearLayout>

package com.example.androidiss;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {
 
 WebView myBrowser;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  myBrowser = (WebView)findViewById(R.id.mybrowser);
  myBrowser.getSettings().setJavaScriptEnabled(true);
  myBrowser.loadUrl("file:///android_asset/isslive.html");
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {

  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }

}

Premission of "android.permission.INTERNET" if needed in AndroidManifest.xml.


download filesDownload the files.

Download APK to run on Android device.

1 comment:

  1. Hi! Nice apps. Can you help me one application?? I'm trying to make gallery with tags. I realised adding tags, but can't make normal galllery. I need a gallery which will show folders(which contain photos) and when i use a OnClickListener they should show me photos in gridview(almost like in standard gallery). If you have so kind of program can you post it?? Or give source code.Thanks.

    ReplyDelete