- 浏览: 375742 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 692转自:http://blog.csdn.net/jgwei/ ... -
tomcat 下jsp乱码的原因分析(上)
2015-09-16 14:10 664转自 http://blog.csdn.net/jgwei/ ... -
JAVA数据源连接方式汇总
2015-07-23 10:28 825一、问题引入 在java程序中,需要访问数据库,做增删改查 ... -
java初始化块和构造方法的执行顺序
2015-06-09 11:18 639初始化块是ja ... -
Java 内存分配全面浅析
2014-02-20 10:56 759本文将由浅入深详细介绍Java内存分配的原理,以帮助新手更 ... -
java 24小时和12小时制
2013-04-12 11:39 1192Date类,已经很少用了。用Calendar吧。 Calen ... -
BlockingQueue
2013-04-08 12:07 983前言: 在新增的Concu ... -
Java NIO框架Netty教程(四) ChannelBuffer(转)
2013-03-01 10:34 8083在学字符串消息收发(ht ... -
Java NIO框架Netty教程(三) 字符串消息收发(转)
2013-03-01 10:31 6346了解了Netty的基本概念( ... -
Java NIO框架Netty教程(二) 白话概念(转)
2013-03-01 10:20 7822"Hello World"的代 ... -
Java NIO框架Netty教程(一) Hello Netty(转)
2013-03-01 10:16 48802先啰嗦两句,如果你还不知道Netty是做什么的能做什么。那 ... -
Netty Channel 接口名词理解
2013-02-28 18:56 29181.Channel channel 是负责数据读,写的对象 ... -
Java中使用默认的密钥库和算法创建数字证书
2012-11-15 09:42 1174★ 实例说明 本实例使 ... -
keystore提取私钥和证书
2012-11-15 09:41 1968keytool -genkey -alias test -ke ... -
详细讲KeyTool
2012-11-15 09:39 1★ 实例说明 本实例使用J2SDK提供的keytool工具 ... -
http获取文件大小
2012-09-21 10:03 2068URL 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...
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,...
在前端开发中,实现FLV(Flash Video)视频的在线播放是常见的需求,尤其是在流媒体服务中。FLV是一种流行的视频格式,它依赖于Adobe Flash Player进行播放。然而,随着HTML5技术的发展,Flash逐渐被淘汰,因此需要...
A media player playing videos from video sites..zip,播放优酷网和其他视频网站视频的视频播放器。
总结来说,FLV Flash播放器是基于Flash技术的视频播放解决方案,而"1.2 Playing video with components"可能涉及到如何使用ActionScript 3.0来创建自定义的视频播放器,包括视频流的获取、播放控制以及与用户的交互...
标题“Stop Auto-Playing videos in Ynet-crx插件”涉及到的是一个针对Ynet网站的浏览器扩展程序,其主要功能是阻止视频自动播放。在现代网络浏览体验中,许多网站为了提升用户体验或增加广告曝光率,会在页面加载时...
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 ...
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 ...
FLV.js提供了丰富的事件接口,如`on('error')`、`on('playing')`等,用于监听播放状态并做出相应处理。同时,还可以通过调用播放器对象的方法来控制播放,如`play()`、`pause()`、`seekTo()`等。 4. **性能优化与...
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 ...
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 ...
在网页中播放视频已经成为现代网页设计不可或缺的一部分,而FLV(Flash Video)格式作为早期流行的视频格式,曾广泛应用于在线流媒体服务。Flowplayer是一款基于Flash技术的开源JavaScript播放器,它支持FLV以及其他...
根据提供的文件信息,我们可以分析并总结出以下关于“VB FLV控件 FLV视频播放器”的相关知识点: ### 一、概述 此VB(Visual Basic)项目为一个FLV视频播放器控件,用于在应用程序中嵌入和播放FLV格式的视频文件。...
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
首先,我们来看“pcgtcg”这个名字,它是“Playing Cards Game”的缩写,暗示了游戏的核心机制——玩家通过收集不同的卡片,构建自己的牌组,进行策略性的对战。在Android平台上,这类游戏的实现通常涉及到以下几个...
在Android开发中,WebView是一个非常重要的组件,它允许我们在应用程序中内嵌网页内容,实现与网页的交互。本文将深入探讨如何在Android的WebView中支持HTML5的video标签内容自动播放,以及相关的优化技巧和注意事项...