Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to play local video #192

Open
ansarikhurshid786 opened this issue Jul 30, 2019 · 9 comments
Open

How to play local video #192

ansarikhurshid786 opened this issue Jul 30, 2019 · 9 comments

Comments

@ansarikhurshid786
Copy link

I am ionic3 framework. I am trying to play video from local like as below :

 let options: StreamingVideoOptions = {
        successCallback: () => {
          console.log('Video played') 
        },
        errorCallback: (e) => { 
          debugger;
          console.log('Error streaming'+e);
        },
        orientation: 'landscape',
        shouldAutoClose: true,
        controls: false
      };
 platform.ready().then(()=>{
        this.streamingMedia.playVideo("./assets/splash.mp4", options);  
        setTimeout(() => {
          this.navCtrl.setRoot(HomePage); 
        }, 5000);

      });

I am getting error :
Error streamingMediaPlayer Error: Unknown (1) 0

can anyone help me ?

@nikeshlive7
Copy link

@ansarikhurshid786 by this time you might have fixed your problem.
I had the same error while playing local video file. Which I fixed by changing the media path as follows:
/data/user/0/appDirectory/pathToTheFile
For Example
/data/user/0/com.test.app/files/200/example.mp4
Hope this helps.

@regnete
Copy link

regnete commented Aug 14, 2019

I cannot play local files on iOS.
Neither native URL nor internal URL of a definitly existing local file work:

Example file URLS:

entry.toNativeURL() : file:///var/mobile/Containers/Data/Application/7BAF2D96-87B6-4255-89C6-345A82B59313/Library/NoCloud/common/binary/raw/1/48/70/34966.mp4

entry.toInternalURL() : cdvfile://localhost/library-nosync/common/binary/raw/1/48/70/34966.mp4

Output from XCode console:

2019-08-14 12:49:57.502740+0200 Demo DEV[3029:927348] videoPlayer starting to play. player=streamingMedia file:///var/mobile/Containers/Data/Application/7BAF2D96-87B6-4255-89C6-345A82B59313/Library/NoCloud/common/binary/raw/1/48/70/34964.mp4
2019-08-14 12:49:57.502830+0200 Demo DEV[3029:927348] playvideo called
2019-08-14 12:49:57.503185+0200 Demo DEV[3029:927348] play called
2019-08-14 12:49:57.503224+0200 Demo DEV[3029:927348] Clean up called
2019-08-14 12:49:57.515653+0200 Demo DEV[3029:927348] startplayer called
2019-08-14 12:49:57.522236+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.522452+0200 Demo DEV[3029:927348] <UITapGestureRecognizer: 0x28059fc00; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleDoubleTapGesture:, target=<AVPlayerViewController 0x1019a0400>)>; numberOfTapsRequired = 2; must-fail-for = {
        <UITapGestureRecognizer: 0x28059c100; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleSingleTapGesture:, target=<AVPlayerViewController 0x1019a0400>)>>
    }>
2019-08-14 12:49:57.522530+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.522652+0200 Demo DEV[3029:927348] <UITapGestureRecognizer: 0x28059c100; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleSingleTapGesture:, target=<AVPlayerViewController 0x1019a0400>)>; must-fail = {
        <UITapGestureRecognizer: 0x28059fc00; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleDoubleTapGesture:, target=<AVPlayerViewController 0x1019a0400>)>; numberOfTapsRequired = 2>
    }>
2019-08-14 12:49:57.524609+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.524812+0200 Demo DEV[3029:927348] <AVUserInteractionObserverGestureRecognizer: 0x280095c00; baseClass = UIGestureRecognizer; state = Possible; cancelsTouchesInView = NO; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleUserInteractionObservationRecognizer:, target=<AVPlayerViewController 0x1019a0400>)>>
2019-08-14 12:49:57.524843+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.524920+0200 Demo DEV[3029:927348] <AVExternalGestureRecognizerPreventer: 0x280091960; baseClass = UIGestureRecognizer; state = Possible; cancelsTouchesInView = NO; view = <AVPlayerViewControllerContentView 0x106507010>>
2019-08-14 12:49:57.524944+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.525049+0200 Demo DEV[3029:927348] <UIPanGestureRecognizer: 0x101138b20; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handlePanGesture:, target=<AVInteractiveTransitionGestureTracker 0x2812cdb20>)>>
2019-08-14 12:49:57.527818+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.528051+0200 Demo DEV[3029:927348] <UIPinchGestureRecognizer: 0x10113a720; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handlePinchGesture:, target=<AVInteractiveTransitionGestureTracker 0x2812cdb20>)>>
2019-08-14 12:49:57.528105+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.528192+0200 Demo DEV[3029:927348] <UIRotationGestureRecognizer: 0x10117f630; state = Possible; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=_handleRotationGesture:, target=<AVInteractiveTransitionGestureTracker 0x2812cdb20>)>>
2019-08-14 12:49:57.528247+0200 Demo DEV[3029:927348] gesture loop
2019-08-14 12:49:57.528388+0200 Demo DEV[3029:927348] <UIScrollViewPanGestureRecognizer: 0x10107cd80; state = Possible; delaysTouchesEnded = NO; view = <AVPlayerViewControllerContentView 0x106507010>; target= <(action=handlePan:, target=<AVPlayerContentTransitioningView 0x101904c00>)>; must-fail = {
        <UIScrollViewPagingSwipeGestureRecognizer: 0x1010abb20; state = Possible; view = <AVPlayerContentTransitioningView 0x101904c00>; target= <(action=_handleSwipe:, target=<AVPlayerContentTransitioningView 0x101904c00>)>>
    }>
2019-08-14 12:49:57.547162+0200 Demo DEV[3029:927348] THREAD WARNING: ['StreamingMedia'] took '44.326904' ms. Plugin should use a background thread.

Screenshot from the iPad:

Image-1

By the way: successCallback and errorCallback are never called on iOS.

On Android local files are played without any issue.

iOS 12.3.1
cordova-ios 5.0.1
cordova-cli 9.0.0

@regnete
Copy link

regnete commented Aug 14, 2019

may be related to ionic-team/cordova-plugin-ionic-webview#134

@regnete
Copy link

regnete commented Aug 14, 2019

looks like my local files have size 0! So its not an issue with this plugin.

@nikeshlive7
Copy link

My issue was exactly like yours and same screen appeared.
@regnete only issue I was facing was file path issue on both android and ios. You can try with following absolute file path structure:
file:///var/mobile/containers/data/Application/path-to-the-application.

@scottopolis
Copy link

You cannot play local audio or video with this plugin on Android from the applicationDirectory, you have to copy the file to the dataDirectory first. See #200

@shamilovtim
Copy link
Collaborator

I'll be looking into this as soon as I have a moment

@pjain168
Copy link

up called
I am also facing similar issue in iOS.

@Lyfei
Copy link

Lyfei commented Apr 11, 2023

I'll be looking into this as soon as I have a moment

What happened afterwards?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants