1

I want to play flv movie downloaded to SD card. I have used example from that topic and after activity is created I can see only LOADING marker with no other effect. Here is my activity Code:

public class VideoActivity extends SherlockFragmentActivity {

private static WebView webView;
private String fileName;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    this.getSupportActionBar().hide();
}

@Override
protected void onResume()
{
    this.initData();
    this.initVideo();
    super.onResume();
}

private void initData()
{
    webView = (WebView)findViewById(R.id.webview);
    this.fileName = getIntent().getExtras().getString("fileName");
}

@SuppressWarnings("deprecation")
@SuppressLint({ "SetJavaScriptEnabled", "SdCardPath" })
private void initVideo()
{              
    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>";

    webView = (WebView) findViewById(R.id.webview);

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setPluginState(PluginState.ON);

    if (!Environment.getExternalStorageState().equals(
            Environment.MEDIA_MOUNTED)) {
        Tool.showInfo(this, "Brak karty SD");
    } else {

        htmlCode = htmlCode.replaceAll("@VIDEO@",  "file://"+Environment.getExternalStorageDirectory()+"/Folder/media/"+this.fileName);
        //webView.loadUrl(htmlCode);
        webView.loadDataWithBaseURL("file://"+Environment.getExternalStorageDirectory()+"/Folder/media/"+this.fileName,  htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null);  
    }
}

What is wrong here? Is there a way to play that FLV file in offline mode???

Community
  • 1
  • 1
MattiahIT
  • 87
  • 9

0 Answers0