nchutchind / cordova-plugin-streaming-media

Simple plugin for loading full screen streaming video or audio.
MIT License
391 stars 285 forks source link

How to play local video #192

Open ansarikhurshid786 opened 5 years ago

ansarikhurshid786 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

may be related to https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/134

regnete commented 5 years ago

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

nikeshlive7 commented 5 years ago

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 commented 5 years ago

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 https://github.com/nchutchind/cordova-plugin-streaming-media/issues/200

shamilovtim commented 5 years ago

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

pjain168 commented 4 years ago

up called I am also facing similar issue in iOS.

Lyfei commented 1 year ago

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

What happened afterwards?