cordova-plugin-ionic-webview: After updating to cordova-plugin-ionic-webview: 2.0.3, unable to load or play locally stored assets from http://localhost:8080 using window.Ionic.WebView.convertFileSrc

Expected Behavior: The new method window.Ionic.WebView.convertFileSrc will work as expected and replace normalizeURL to allow locally stored videos/photos/audio files to be accessed/played.

Actual Behavior: The videos/audio files/images served at localhost:8080/_file_/ … (which is the new formatted file location by the suggested method) will not load or play. Have tried running this.renderer.invokeElementMethod(video, ‘load’); this.renderer.invokeElementMethod(video, ‘play’); video.load(); video.play();

I believe the load method works because it immediately hits an error with let canPlayThrough = this.renderer.listen(video, ‘canPlayThrough’, (evt) => }); Error output here is evt { bubbles: false cancelBubble: false cancelable: true composed: false currentTarget: null defaultPrevented: false eventPhase: 0 isTrusted: true returnValue: true srcElement: <video> target: <video> timeStamp: 72999 type: “error” }

Has anybody run into this issue yet/solved it? I was already using WKWebview with everything working perfectly, the reason this became an issue (I believe) is the deprecation of normalizeURL. Any ideas or tips would be awesome.

UPDATE: If I hardcode one of the file URLs into the video tag it hits a 500 Internal Server Error multiple times before giving up. If I load this same URL in a chrome browser, it locates and plays the media file without issue.

Config.xml <access origin="http://localhost:8080" /> <allow-navigation href="http://localhost:8080/*" /> <allow-intent href="http://localhost:8080/*" />

Packages: Angular CLI: 1.7.4 Node: 6.11.0 OS: darwin x64 Angular: 5.2.11 … animations, common, compiler, compiler-cli, core, forms … http, platform-browser, platform-browser-dynamic … platform-server, router

@angular/cli: 1.7.4 @angular/tsc-wrapped: 4.4.6 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.2 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.6.2 webpack: 3.11.0

“dependencies”: { “@angular/animations”: “^5.2.11”, “@angular/common”: “^5.2.11”, “@angular/compiler”: “^5.2.11”, “@angular/compiler-cli”: “^5.2.11”, “@angular/core”: “^5.2.11”, “@angular/forms”: “^5.2.11”, “@angular/http”: “^5.2.11”, “@angular/platform-browser”: “^5.2.11”, “@angular/platform-browser-dynamic”: “^5.2.11”, “@angular/platform-server”: “^5.2.11”, “@angular/router”: “^5.2.11”, “@ionic-native/app-rate”: “^4.6.0”, “@ionic-native/app-version”: “^3.12.1”, “@ionic-native/background-mode”: “^3.12.1”, “@ionic-native/camera”: “^3.12.1”, “@ionic-native/clipboard”: “^4.10.0”, “@ionic-native/core”: “3.10.2”, “@ionic-native/deeplinks”: “^3.12.1”, “@ionic-native/device”: “^3.12.1”, “@ionic-native/email-composer”: “^3.12.1”, “@ionic-native/facebook”: “^3.12.1”, “@ionic-native/file”: “^4.5.3”, “@ionic-native/file-transfer”: “^4.10.0”, “@ionic-native/google-plus”: “^3.12.1”, “@ionic-native/health”: “^3.12.1”, “@ionic-native/health-kit”: “^4.7.0”, “@ionic-native/http”: “^3.12.1”, “@ionic-native/in-app-browser”: “^3.5.0”, “@ionic-native/insomnia”: “^3.12.1”, “@ionic-native/keyboard”: “^3.12.1”, “@ionic-native/local-notifications”: “^3.14.0”, “@ionic-native/market”: “^4.7.0”, “@ionic-native/media”: “^4.3.1”, “@ionic-native/mixpanel”: “^4.1.0”, “@ionic-native/native-audio”: “^4.3.1”, “@ionic-native/native-storage”: “^3.12.1”, “@ionic-native/network”: “^3.12.1”, “@ionic-native/onesignal”: “^4.2.1”, “@ionic-native/photo-viewer”: “^4.5.2”, “@ionic-native/safari-view-controller”: “^3.12.1”, “@ionic-native/screen-orientation”: “^3.12.1”, “@ionic-native/social-sharing”: “^3.12.1”, “@ionic-native/splash-screen”: “^3.10.2”, “@ionic-native/status-bar”: “^3.13.1”, “@ionic-native/streaming-media”: “^3.14.0”, “@ionic-native/transfer”: “^3.12.1”, “@ionic-native/wheel-selector”: “^4.2.1”, “@ionic-native/youtube-video-player”: “^4.10.0”, “@ionic/cloud-angular”: “0.12.0”, “@ionic/storage”: “^2.0.1”, “@ng-bootstrap/ng-bootstrap”: “^1.0.0-alpha.18”, “@types/moment-timezone”: “^0.2.34”, “acorn-dynamic-import”: “^2.0.2”, “app-scripts”: “0.0.0”, “async”: “^2.4.0”, “chalk”: “^2.1.0”, “com-sarriaroman-photoviewer”: “^1.1.11”, “cordova-android”: “^6.4.0”, “cordova-android-play-services-gradle-release”: “0.0.2”, “cordova-custom-config”: “^4.0.2”, “cordova-ios”: “~4.5.4”, “cordova-plugin-app-version”: “^0.1.9”, “cordova-plugin-background-mode”: “^0.7.2”, “cordova-plugin-camera”: “^2.4.1”, “cordova-plugin-compat”: “^1.2.0”, “cordova-plugin-console”: “^1.1.0”, “cordova-plugin-crosswalk-webview”: “^2.2.0”, “cordova-plugin-device”: “^1.1.6”, “cordova-plugin-email”: “^1.2.6”, “cordova-plugin-facebook4”: “^1.7.4”, “cordova-plugin-file”: “^4.3.3”, “cordova-plugin-geolocation”: “^2.4.3”, “cordova-plugin-googleplus”: “^5.1.1”, “cordova-plugin-health”: “^0.10.1”, “cordova-plugin-http”: “^1.2.0”, “cordova-plugin-inappbrowser”: “^1.6.1”, “cordova-plugin-insomnia”: “https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git”, “cordova-plugin-ionic-webview”: “^2.0.3”, “cordova-plugin-local-notifications”: “https://github.com/katzer/cordova-plugin-local-notifications.git#ios10”, “cordova-plugin-mixpanel”: “^4.0.0”, “cordova-plugin-music-controls”: “https://github.com/amitkhare/cordova-music-controls-plugin.git”, “cordova-plugin-nativestorage”: “^2.2.2”, “cordova-plugin-network-information”: “^1.3.3”, “cordova-plugin-safariviewcontroller”: “^1.4.7”, “cordova-plugin-screen-orientation”: “^2.0.1”, “cordova-plugin-splashscreen”: “^4.0.3”, “cordova-plugin-statusbar”: “^2.4.1”, “cordova-plugin-whitelist”: “^1.3.2”, “cordova-plugin-x-socialsharing”: “^5.1.8”, “cordova-wheel-selector-plugin”: “^1.0.9”, “crypto-js”: “^3.1.9-1”, “es6-promise-plugin”: “^4.1.1”, “hammerjs”: “^2.0.8”, “ionic-angular”: “^3.8.0”, “ionic-plugin-deeplinks”: “^1.0.15”, “ionic-plugin-keyboard”: “^2.2.1”, “ionicons”: “3.0.0”, “json-loader”: “^0.5.7”, “loader-runner”: “^2.3.0”, “moment-timezone”: “^0.5.17”, “node-sass”: “^4.5.3”, “onesignal-cordova-plugin”: “^2.2.2”, “rollup-pluginutils”: “^2.0.1”, “rxjs”: “^5.5.11”, “sw-toolbox”: “3.6.0”, “typescript”: “^2.4.2”, “zone.js”: “^0.8.26” }, “devDependencies”: { “@ionic/app-scripts”: “^3.1.2”, “@types/async”: “2.0.40”, “ionic”: “3.20.0”, “typescript”: “2.4.2” }

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Merged. Thanks for testing!

Just to confirm this is also working for me with video and audio in 2 separate Apps

@jcesarmobile the range request setting is still there but only defined on root path. Now there is a second get handler path defined for file. I believe this would also need the allow range requests setting.

If this doesn’t work then it can be fixed by setting behaviour for specific media file extensions but this would be a last option as it would be a pain to maintain.

I just haven’t had time to test this yet, sorry, I will try and test it with one of my apps this week.

this is the solution I have seen which relies on defining supported file extensions: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/134#issuecomment-408742803