Dringend! lokales video aus webview starten

A

aapp

Neues Mitglied
0
bissher war meine intensive suche erfolglos :-(
ich will ein video das lokal liegt per Link im webview, starten.

-> es muss vom webview aus sein, also per link (egal wie), so dass ich nur die links anpassen auf ein neues video.
-> es darf wegen dem traffic nicht auf dem server liegen, nur lokal
-> videoformat ist egal hauptsache da bewegt sich was.

mir ist auch egal ob nun dort ein mediaplayer, brwoser oder sonst was geöffnet wird. also per klick auf link = video.

hier mein aktueller code, mit dem ich sehr weit schon komme:

Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] dasDing [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Activity {[/SIZE]
[LEFT][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]/** Called when the activity is first created. */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f5fbf]
[/COLOR][/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#646464]
[/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onCreate(Bundle savedInstanceState) {[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onCreate(savedInstanceState);[/SIZE]
[SIZE=2]setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
 
 
[LEFT][SIZE=2]WebView webview = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] WebView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]WebSettings webSettings = webview.getSettings(); [/SIZE]
[SIZE=2]webSettings.setJavaScriptEnabled([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]); [/SIZE]
[SIZE=2]webview.getSettings().setJavaScriptCanOpenWindowsAutomatically([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]webSettings.setPluginsEnabled([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]); [/SIZE]
[SIZE=2]webSettings.setLoadsImagesAutomatically([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]); [/SIZE]
[SIZE=2]webSettings.setSupportZoom([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]webview.getSettings().setAllowFileAccess([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]webview.setWebViewClient([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArticleWebViewClient()); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]webview.loadUrl([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"file:///android_asset/index.htm"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE]
[SIZE=2]setContentView(webview); [/SIZE]
[SIZE=2]webview.setInitialScale(100);[/SIZE][/LEFT]
 
 
 
[LEFT][SIZE=2]}[/SIZE][/LEFT]
 
 
 
 
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArticleWebViewClient [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] WebViewClient { [/SIZE]
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]boolean[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] shouldOverrideUrlLoading(WebView view, String url) { [/SIZE][/LEFT]
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (url.endsWith([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]".m4v"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])) { [/SIZE]
[SIZE=2]Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent(Intent.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ACTION_VIEW[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]); [/SIZE]
[SIZE=2]intent.setDataAndType(Uri.[I]parse[/I](url), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"video/*"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE]
[SIZE=2]view.getContext().startActivity(intent); [/SIZE][/LEFT]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]; [/SIZE][/LEFT]
 
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] { [/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]; [/SIZE]
[SIZE=2]} [/SIZE]
[SIZE=2]} [/SIZE][/LEFT]
 
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onPageFinished(WebView view, String url) { [/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onPageFinished(view, url); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]} [/SIZE]
[SIZE=2]} [/SIZE][/LEFT]

der entsprechende HTML-Code:

Code:
  <a href="vid.m4v">video</a><br>
  <a href="file:///android_asset/vid.m4v">video_assets</a><br>

natürlich liegen index.html + vid.m4v im gleichen verzeichnis.


Es wird tatsächlich ein player geöffnet und dieser meldet dann
"sorry, this video cannot be played" (in der emu) und "unbekannter dateityp" auf dem handy..... natürlich kann das handy das video abspielen. habe es mit dem gerät aufgenommen und wenn ich es anklicke auf dem handy spielt es ab.. mp4/m4v, wmv, usw.

kann mir jemand weiterhelfen? das problem ärgert mich schon einige tage.

permissions = nur "Internet" gesetzt, fehlt ggf etwas?

[/LEFT]
 
Hast du schon probiert in dem Link eine Javascript Funktion aufzurufen die wiederum eine Java Funktion aufruft in der ein passender Intent mit extras Action.View und dem Videofile steht?
Der direkt Pfad zum Video im HTML schaut irgendwie komisch und falsch aus.
 
strider schrieb:
Hast du schon probiert in dem Link eine Javascript Funktion aufzurufen die wiederum eine Java Funktion aufruft in der ein passender Intent mit extras Action.View und dem Videofile steht?
Der direkt Pfad zum Video im HTML schaut irgendwie komisch und falsch aus.

naja für andere Files klappt der direkte aufruf z.b. href="vid.m4v" wunderbar. Bin mir nicht sicher ob ggf. der pfad für den player anders sein muss, da dieser ggf. auf einer anderen ebene arbeitet. also mit dem relativen pfad nicht klar kommt. daher habe ich beide varianten versucht.

selbst wenn ich einen total falschen pfad angebe kommt die meldung. im player aber steht für kurze zeit sichtbar "vid.m4v", als wollte er es öffnen.

oder ob es am mimetype liegt? am Format sollte es eigentlich nicht liegen, da der gleiche player ja das file öffnen kann, wenn mans manuell holt.

vermute das problem mit der URL zu player.
 

Ähnliche Themen

Laser5001
  • Laser5001
Antworten
2
Aufrufe
898
Laser5001
Laser5001
R
  • Robby1950
2
Antworten
23
Aufrufe
1.012
Robby1950
R
5
Antworten
0
Aufrufe
1.143
586920
5
Zurück
Oben Unten