- 浏览: 369342 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
wangchong_kevin:
放在drawable-hdpi目录下的图片,如果在mdpi分辨 ...
BitmapFactory.Options 解决加载大图片OOM -
darren_nizna:
Netty 实战(精髓) http://gitlore. ...
Java NIO框架Netty教程(一) Hello Netty(转) -
大家来学习:
国内首部NIO+Netty5各种RPC架构实战演练课程观看地址 ...
Java NIO框架Netty教程(一) Hello Netty(转) -
lipeixiaoyu:
[color=red][/color]123
IOS UIView的clipsToBounds属性 -
ramon1989:
问一下,你的SimpleChannelHandler是哪个包下 ...
Java NIO框架Netty教程(一) Hello Netty(转)
Often when you create an app displaying web contents in a mobile device you have to deal with FLV videos, still widely used in the web (until HTML5 will rule the world). The best thing to do is to convert them with some converter (like ffmpeg), but if you don'have access to original videos or for some other reasons you can't do the conversion in some other suitable format, here you can find a quick tutorial on how to embed and play Flash FLV Videos in an Android application.
This is done by using a WebView, a SWF player capable of playing FLVs, and of course the Flash plugin for Android installed.
First, create a layout xml with a WebView, like this:
then, create the Activity class, here is an extract:
Some explanation:
This is done by using a WebView, a SWF player capable of playing FLVs, and of course the Flash plugin for Android installed.
First, create a layout xml with a WebView, like this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <WebView android:layout_width="fill_parent" android:id="@+id/webview" android:layout_height="fill_parent"></WebView> </LinearLayout>
then, create the Activity class, here is an extract:
package it.synesthesia.flvplayer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLEncoder; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.webkit.WebView; public class ViewVideo extends Activity { WebView webView; String htmlPre = ""; String htmlCode = " " + ""; String htmlPost = ""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_video); webView = (WebView)findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setPluginsEnabled(true); webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); //thanks Patrick! htmlCode = htmlCode.replaceAll("@VIDEO@", video_link); webView.loadDataWithBaseURL("fake://fake/fake", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null); } @Override protected void onPause(){ super.onPause(); callHiddenWebViewMethod("onPause"); webView.pauseTimers(); if(isFinishing()){ webView.loadUrl("about:blank"); setContentView(new FrameLayout(this)); } } @Override protected void onResume(){ super.onResume(); callHiddenWebViewMethod("onResume"); webView.resumeTimers(); } private void callHiddenWebViewMethod(String name){ // credits: http://stackoverflow.com/questions/3431351/how-do-i-pause-flash-content-in-an-android-webview-when-my-activity-isnt-visible if( webView != null ){ try { Method method = WebView.class.getMethod(name); method.invoke(webView); } catch (NoSuchMethodException e) { Lo.g("No such method: " + name + e); } catch (IllegalAccessException e) { Lo.g("Illegal Access: " + name + e); } catch (InvocationTargetException e) { Lo.g("Invocation Target Exception: " + name + e); } } } }
Some explanation:
- as said, you need a FLV player. I used the great & free FLVPlayer http://www.platipus.nl/flvplayer/download/1.0/
- FLV player must reside on a website on the net. I tried putting the .swf in the /assets folder of the app and calling it from there, but it failed to load the FLV video. if someone can fix this please let me know!
- callHiddenWebViewMethod is very important, otherwise the video will continue playing when the activity is not visible any more (and audio as well). Credis to this goes to the sliseshare poster linked in the comment. Thanks!
- WARNING: this is mostly an hack! beware, things could not work as expected, or can stop working in the future. Btw, it worked very well for me.
- Have fun and let me know if you use this code! Francesco Ronchi (francesco [dot] ronchi [at] synesthesia [dot] it)
htmlCode contains the code to show the video as "fullscreen" (filling to full size of the webview). I could not get rid of a small white row some pixel wide, that I suppose is the space for the webview scrollbar. If you found workaround for this, again, please let me know so I can update the tutorial thanks to Patrick van Coeverden for the fix suggestion - see http://stackoverflow.com/questions/2279978/webview-showing-white-bar-on-right-side
发表评论
-
tomcat下jsp乱码原因(下)
2015-09-16 14:13 664转自:http://blog.csdn.net/jgwei/ ... -
tomcat 下jsp乱码的原因分析(上)
2015-09-16 14:10 632转自 http://blog.csdn.net/jgwei/ ... -
JAVA数据源连接方式汇总
2015-07-23 10:28 737一、问题引入 在java程序中,需要访问数据库,做增删改查 ... -
java初始化块和构造方法的执行顺序
2015-06-09 11:18 604初始化块是ja ... -
Java 内存分配全面浅析
2014-02-20 10:56 727本文将由浅入深详细介绍Java内存分配的原理,以帮助新手更 ... -
java 24小时和12小时制
2013-04-12 11:39 1148Date类,已经很少用了。用Calendar吧。 Calen ... -
BlockingQueue
2013-04-08 12:07 929前言: 在新增的Concu ... -
Java NIO框架Netty教程(四) ChannelBuffer(转)
2013-03-01 10:34 8058在学字符串消息收发(ht ... -
Java NIO框架Netty教程(三) 字符串消息收发(转)
2013-03-01 10:31 6249了解了Netty的基本概念( ... -
Java NIO框架Netty教程(二) 白话概念(转)
2013-03-01 10:20 7775"Hello World"的代 ... -
Java NIO框架Netty教程(一) Hello Netty(转)
2013-03-01 10:16 48749先啰嗦两句,如果你还不知道Netty是做什么的能做什么。那 ... -
Netty Channel 接口名词理解
2013-02-28 18:56 28381.Channel channel 是负责数据读,写的对象 ... -
Java中使用默认的密钥库和算法创建数字证书
2012-11-15 09:42 1132★ 实例说明 本实例使 ... -
keystore提取私钥和证书
2012-11-15 09:41 1885keytool -genkey -alias test -ke ... -
详细讲KeyTool
2012-11-15 09:39 1★ 实例说明 本实例使用J2SDK提供的keytool工具 ... -
http获取文件大小
2012-09-21 10:03 2009URL url = new URL(downloadUrl); ... -
android内存管理
2012-03-16 10:56 1很多开发者都是从j2me或j2ee上过来的,对于内存的使用和理 ... -
调用Android系统“应用程序信息(Application Info)”界面
2012-02-21 18:45 0“Android系统设置->应 ... -
AsyncTask解决Android UI堵塞问题
2012-02-17 14:54 0AsyncTask解决Android UI堵 ... -
15个非常有用的Android代码
2012-02-17 14:53 015个非常有用的Android代码 1:查看 ...
相关推荐
Want to get started building applications for Android, the world’s hottest, fast-growing mobile platform? Already building Android applications and want to get better at it? This book brings together...
Part 3 Android applications 12 Putting it all together–the Field Service Application 12.1 Field Service Application requirements 12.2 Android application tour 12.3 Android code 12.4 Digging deeper ...
The Android Developer's Cookbook Building Applications with the Android SDK and Source Project Code 源书(pdf)及源代码12章全都有(rar) Book Description Want to get started building applications for ...
The video keeps on playing when the app is turned in to Picture-in-Picture mode. On Picture-in-Picture screen, the app shows an action item to pause or resume the video. Introduction As of Android O,...
A media player playing videos from video sites..zip,播放优酷网和其他视频网站视频的视频播放器。
Using the essential parts of Android applications, such as user interface components, notifications, and resources Storing and accessing data using Android APIs Accessing device location and using ...
Native Android Applications Android SDK Features Introducing the Open Handset Alliance What Does Android Run On? Why Develop for Mobile? Why Develop for Android? Introducing the Development Framework ...
I wanted to keep playing this game on Android O, so lifted the source from AOSP, cleaned it up a bit, fixed some things, put it in a Bazel workspace, and published it on Google Play Store. How to ...
“Wolfenstein 3D”-like and ”Doom”-like game apps are some of the classic Android games presented in the original edition of this book. Since their release, Android has progressed with the debut of ...
pcgtcg Playing Cards Game 适用于 Android 的集换式卡牌游戏
provided by Sothink Web Video Downloader, can detect any online videos played in your browser, and prompt you to download video with one-click.With the built-in Flash Video Player, playing the ...
You will also create beautiful and responsive menus and dialogs and explore the different options for playing sound effects and music in Android. You will then learn the basics of creating a ...
Mobile Flash Player 10.1 Versus AIR 2.6 on Android Chapter 2 : Call Me, Text Me Setting Up Your Device Creating a Project Creating the Application Descriptor Writing the Code Packaging Your ...
Native Android Applications 4 Android SDK Features 5 Access to Hardware including Camera, GPS, and Accelerometer 6 Native Google Maps, Geocoding, and Location-Based Services 6 Background Services...
inline-youtube-view YouTube component for Android, iOS and React. This is a suite of utility libraries around using ...Playing them inline where in a list you can have more than one videos in a singl
A Music Player for android that makes use of the Visualzer Class for rendering a beautiful **DNA** (***Visualization***) of the currently playing music. Background The Music Player draws inspiration ...
Mobile Flash Player 10.1 Versus AIR 2.6 on Android Chapter 2 : Call Me, Text Me Setting Up Your Device Creating a Project Creating the Application Descriptor Writing the Code Packaging Your ...
Learn RPGs in GameMaker: Studio Build and Design Role Playing Games By Ben Tyers English | PDF | 2017 | 310 Pages | ISBN : 1484229452 | 13.31 MB Carry out the pre-planning, design, and programming of...
语言:עברית 停止在装箱中的自动播放视频。 插件,可防止在浏览卫星时自动激活视频 只是安装和享受 停止在yET中的自动播放视频