Is it possible out of the box or via a library?
MX Player Android. MX Player can play flv video that are downloaded from youtube, myspace, hullu etc. It can also play the video directly from the web on the Android device.
For playing videos in all key formats, including FLV, Xtreme Media Player is one of the best player apps for Android devices. The app also supports playing the files on the discs and from the streaming protocols. The player comes with filters and equalizers and offers subtitle and gestures support.
Step 1: Download an FLV compatible media player from the media player's official website. Step 2: Launch the media player on your computer. Step 3: Drag and drop the FLV file that you wish to play; otherwise, right-click on the file, and choose from the list of media players.
Unfortunately, Adobe has discontinued all support for Flash and Flash Player is no longer supported by any of the major web browsers. You can open FLV files in third-party media players like VLC on PC and Mac, or PlayerXtreme on iPhone and Android devices.
you can play FLV using flash plugin inside a WebView. see here: http://www.synesthesia.it/playing-flash-flv-videos-in-android-applications
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:
<?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 = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"></head><body style='margin:0; pading:0; background-color: black;'>";
String htmlCode =
" <embed style='width:100%; height:100%' src='http://www.platipus.nl/flvplayer/download/1.0/FLVPlayer.swf?fullscreen=true&video=@VIDEO@' " +
" autoplay='true' " +
" quality='high' bgcolor='#000000' " +
" name='VideoPlayer' align='middle'" + // width='640' height='480'
" allowScriptAccess='*' allowFullScreen='true'" +
" type='application/x-shockwave-flash' " +
" pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
"";
String htmlPost = "</body></html>";
@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:
No, it's not possible. The OpenCORE media library that's providing the media playback on Android doesn't support .flv files.
You can find a list of supported media formats here. These formats are supported on generic Android. On the same page you will find some additional formats that the T-Mobile G1 supports.
Of course, support for additional media formats might be possible on specific devices. But this can vary from device to device.
Try vitamio. It is a library similar to mediaplayer which can be imported into your project very easily. The only thing is that it supports flv video files too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With