0

Using the nativescript-videoplayer plugin with Angular I am able to view and play videos remotely and locally on IOS. However on Android I am only able to play remote videos. For local videos, the video player is displayed, but the time is at 0.00 and there is no picture, which usually means that the video source cannot be found.

I have tried specifying the source with these following paths:

src="res://videos/test.mp4"
src="~/videos/test.mp4"

And have tried placing the location of the video under:

App_Resources/videos/test.mp4
App_Resources/android/videos/test.mp4
App_Resources/android/src / main/videos.test.mp4

For a simplified example I added the local videos to this simple playground: https://play.nativescript.org/?template=play-ng&id=lCu2B5&v=50

  • You can simply put video under your src folder, but you will have to adjust your webpack config to include the mp4 file in bundling. – Manoj Dec 31 '19 at 15:14
  • @Manoj could you show me what that would look like in the webpack.config.js file? And how would you reference that in the src="" for the video? – WJosh Vetter Dec 31 '19 at 16:30
  • Does this answer your question? [Nativescript: Transferring mp3 files with Sidekick](https://stackoverflow.com/questions/52591357/nativescript-transferring-mp3-files-with-sidekick) – Manoj Jan 01 '20 at 03:30
  • In the linked answer, I had demonstrated how you could copy audio files, basically you just have to let webpack know you are using those files at run time. Instead of songs in the example, you are going to use videos directory with mp4 files within. – Manoj Jan 01 '20 at 03:32

1 Answers1

0

You can put your video file in any folder under your app src. But to be able to play it, you need to get the full absolute path of the video to put it to the src property of video player. Example that you have your app's src folder > videos > test.mp4. You can get the path to your mp4 file with Nativescript fileModule.

fileModule.path.normalize(fileModule.knownFolders.currentApp().path + "///videos///test.mp4");
Juky
  • 121
  • 7