Coder Social home page Coder Social logo

nstudio / nativescript-videoplayer Goto Github PK

View Code? Open in Web Editor NEW
131.0 8.0 60.0 38.14 MB

:clapper: Video Player widget for NativeScript apps

License: MIT License

TypeScript 93.70% JavaScript 1.10% Shell 1.94% CSS 1.49% HTML 1.77%
nativescript nativescript-plugin typescript android ios video-player

nativescript-videoplayer's Introduction

A NativeScript plugin to provide the ability to play local and remote videos.

Build CI npm npm


Installation

From your command prompt/terminal go to your app's root folder and execute:

NativeScript Version 7+: tns plugin add nativescript-videoplayer

NativeScript version prior to 7: tns plugin add [email protected]

Platform controls used:

Android iOS
Android MediaPlayer iOS AVPlayer
Sample 1 Sample 2
Sample Usage Sample 2

Usage

<Page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:VideoPlayer="nativescript-videoplayer">
        <StackLayout>

            <VideoPlayer:Video id="nativeVideoPlayer"
            controls="true" loop="true" autoplay="false" height="280"
            src="~/videos/big_buck_bunny.mp4" />

            <!-- Remote file to test with https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4 -->

        </StackLayout>
</Page>
import { Video } from 'nativescript-videoplayer';

const video = topmost().currentPage.getViewById('nativeVideoPlayer') as Video;
// Setting event listeners on the Video
video.on(Video.pausedEvent, () => {
  console.log('Video has been paused.');
});

video.on(Video.mutedEvent, () => {
  console.log('Video has been muted.');
});

// changing the src
video.src = 'some video file or url';

// set loop
video.loop = false;

Angular NativeScript Usage

// somewhere at top of your component or bootstrap file
import { registerElement } from '@nativescript/angular';
import { Video } from '@nstudio/nativescript-exoplayer';
registerElement('VideoPlayer', () => Video);
// documentation: https://docs.nativescript.org/angular/plugins/angular-third-party.html#simple-elements

With AngularNative you have to explicitly close all components so the correct template code is below.

  <VideoPlayer
      src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
      autoplay="true"
      height="300"></VideoPlayer>

Properties

Property Description
src The src file for the video. Set the video file to play, for best performance use local video files if possible. The file must adhere to the platforms accepted video formats. For reference check the platform specs on playing videos.
autoplay - (boolean) Set if the video should start playing as soon as possible or to wait for user interaction.
controls - (boolean) Set to use the native video player's media playback controls.
muted - (boolean) Mutes the native video player.
loop - (boolean) Sets the native video player to loop once playback has finished.
fill - (boolean) If true, the aspect ratio of the video will not be honored and it will fill the entire space available.
observeCurrentTime - (boolean) If true, currentTimeUpdated callback is possible.
headers - (Map<string, string>) Set headers to add when loading a video from URL.

API

Method Description
play Start playing the video.
pause Pause the video
seekToTime(time: number) Seek the video to a time (milliseconds)
getCurrentTime Returns the current time in the video duration (milliseconds)
getDuration Returns the current time in the video duration (milliseconds)
destroy Destroy the video player and free resources
mute(boolean) If true, mutes the video. If false, unmute the video.
setVolume(volume: number) Set the volume - Must be between 0 and 1.
ANDROID ONLY - stop Stop the playback - this resets the player and remove the video src

Observable Properties

  • currentTime() - Current time of video.

Events

Event Description
errorEvent This event fires when an error in the source code is thrown.
playbackReadyEvent This event fires when the video is ready.
playbackStartEvent This event fires when video starts playback.
seekToTimeCompleteEvent This event fires when seeking is complete.
currentTimeUpdatedEvent This event fires when the current time of playing video is changed.
finishedEvent This event fires when the video is complete.
mutedEvent This event fires when video is muted.
unmutedEvent This event fires when video is unmutedEvent.
pausedEvent This event fires when video is paused.
volumeSetEvent This event fires when the volume is set.

iOS Logging

When running the iOS Simulator, after playing a video the iOS system may write log messages to the console every few seconds of the form

[aqme] 254: AQDefaultDevice (173): skipping input stream 0 0 0x0

They will continue being logged even after the video has been properly destroyed. These messages can be safely ignored. To turn them off completely, run the following command in your shell before running tns run ios:

export SIMCTL_CHILD_OS_ACTIVITY_MODE="disable"

nativescript-videoplayer's People

Contributors

alexziskind1 avatar bnussey avatar bradmartin avatar brianrclow avatar eddyverbruggen avatar edusperoni avatar ivshti avatar juanmcampos avatar markhatchell avatar nathanaela avatar souly1 avatar surdu avatar zangarmarsh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-videoplayer's Issues

"finished" is not working under Angular2

Following your specific guidelines for Angular in Readme the video is playing but when finished the function specified in the "finished" property is not fired. What could be the problem?

This is my app.component.html


This is my app.component.ts

import { Component } from "@angular/core";
import {registerElement} from "nativescript-angular/element-registry";
registerElement("VideoPlayer", () => require("nativescript-videoplayer").Video);

@component({
selector: "my-app",
templateUrl: "app.component.html",
})
export class AppComponent {

public onFinished() {
    console.log ('Video finished playing.')
}

}

Please, help.

Plugin Works on Emulator but not on the device

After the last {N} update (2.5) the plugin stopped to work on the device.

I followed the steps described here https://bradmartin.net/2016/07/20/ahhh-this-nativescript-plugin-doesnt-work/ but still doesn`t work.

Can someone help me?

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x10118b7b4 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x101a172dc ffi_closure_SYSV_inner
3   0x101a181b4 .Ldo_closure
4   0x18d97a924 <redacted>
5   0x18d97a4ec <redacted>
6   0x18d980c98 <redacted>
7   0x18d97e138 <redacted>
8   0x19bc8e23c <redacted>
9   0x18d9f068c <redacted>
10  0x101a18044 ffi_call_SYSV
11  0x101a16e1c ffi_call_int
12  0x101a16934 ffi_call
13  0x10114d4fc NativeScript::FFICall::call(JSC::ExecState*)
14  0x101781890 JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCal
lLinkInfo*)
15  0x101789f18 llint_entry
16  0x101783808 vmEntryToJavaScript
17  0x10172329c JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
18  0x101700238 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue,
JSC::ArgList const&)
19  0x1018c40ac JSC::boundThisNoArgsFunctionCall(JSC::ExecState*)
20  0x10178a8f4 llint_entry
21  0x101789f28 llint_entry
22  0x101783808 vmEntryToJavaScript
23  0x10172329c JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
24  0x101700238 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue,
JSC::ArgList const&)
25  0x10114ff9c NativeScript::FFICallback<NativeScript::ObjCBlockCallback>::callFunction(JSC::JSValue const&, JSC::ArgList const&,
 void*)
26  0x10118b398 NativeScript::ObjCMethodCallback::ffiClosureCallback(void*, void**, void*)
27  0x10118b79c NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
28  0x101a172dc ffi_closure_SYSV_inner
29  0x101a181b4 .Ldo_closure
30  0x187a5eb10 <redacted>
31  0x187a5e214 <redacted>
JavaScript stack trace:
1   @file:///app/tns_modules/tns-core-modules/ui/builder/builder.js:175:56
2   @file:///app/tns_modules/tns-core-modules/xml/xml.js:147:20
3   parse@file:///app/tns_modules/tns-core-modules/js-libs/easysax/easysax.js:751:34
4   parse@file:///app/tns_modules/tns-core-modules/xml/xml.js:194:27
5   parse@file:///app/tns_modules/tns-core-modules/ui/builder/builder.js:181:32
6   parseInternal@file:///app/tns_modules/tns-core-modules/ui/builder/builder.js:48:16
7   loadInternal@file:///app/tns_modules/tns-core-modules/ui/builder/builder.js:133:40
8   load@file:///app/tns_modules/tns-core-modules/ui/builder/builder.js:117:39
9   pageFromBuilder@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:111:31
10  resolvePageFromEntry@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:89:35
11  navigate@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:165:40
12  navigate@file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:44:43
13  onLoaded@file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:38:26
14  viewDidLoad@file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:404:27
15  makeKeyAndVisible@[native code]
16  didFinishLaunchingWithOptions@file:///app/tns_modules/tns-core-modules/application/application.js:144:39
17  @[native code]
18  onReceive@file:///app/tns_modules/tns-core-modules/application/application.js:59:32
19  UIApplicationMain@[native code]
20  start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26
21  anonymous@file:///app/app.js:101:18

Bind Video Source

How can I bind Video src???

// Example 1 WORKING

<VideoPlayer:Video loaded="videoplayerLoaded" finished="videoFinished" autoplay="false" height="200" src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />

// Example 2 NOT WORKING

<VideoPlayer:Video loaded="videoplayerLoaded" finished="videoFinished" autoplay="false" height="200" src="{{ video }}" />

{N} 1.6 not working

After upgrading to the latest version of {N} the player is no longer showing the video. I can hear the sound playing but nothing is being shown :( I am talking about Android here.

Video.destroy() doesn't work

Okay, so I have this code

var old_video = page.getViewById("video");
if(old_video !== undefined) {
    old_video.destroy();
}

But when I run it, the video freezes and the controls stop working, but the video won't disappear. BUT! If I run the code a second time, it says Cannot read property 'stopPlayback' of null'. So why is the video not disappearing? Is there something I'm doing wrong??

calling components functions using Angular Native.

I am using Angular Native and its working fine to display the video. Now I want to call the api functions e.g pause() from a another button tap. How do I do this? I am using type script and I only have access to VideoPlayer in html file. I tried with a local variabel <VideoPlayer #vPlayer, and then call vPlayer.pause() from a button (tap) event but it doesn't work. Also I was wondering if I can have access to instance of this in my compnent (.ts file), I can then call the events. Please help how should I get this working. Thanks.

[Android] Cannot see controls

Updated to the latest version the other day, testing on Android, I am not seeing any player controls (controls is set to true in xml).

Can not change video-source to play other Video-file

Hello !
I am trying to deploy my code to Android. This works fine on Iphone but not on Android.
I have in my xml, the following:
<VideoPlayer:Video id="nativeVideoPlayer" width="100%" height="90%"
verticalAlignment="middle"
src=" {{ urlsrc }} "
loaded="{{ videoplayerLoaded }}"
finished="{{ videoFinished }}"
autoplay="true"
left="0" top="40"
/>

I am trying to change the src property of the Video in my Typescript.code as follows:

this._videoPlayer.src = 'https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4';
this.playVideo();

I have even tested with the following without result:
this.set("urlsrc", 'https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4');
or
this.src = 'https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4';

Still same problem, I can not change the video-source or replace it with another video-force. I can only play first video-file and can not change and play other video-files. As stated I do not have any such problem in Iphone to change Video-source using this.set("urls",...).

When I compile it via tsc, I get the following complain:
error TS2339: Property 'src' does not exist on type 'Video'.

Any idea why I have this problem ?

Not working

doesnt matter what i do the screen is all white, i only can hear the video but cant see it.

Cannot play remote video

Hi @bradmartin
I'm trying to play remote video by changing the source content with the link as
src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4". I've an error CAN'T PLAY VIDEO on android 4.4.2.

I'll like to know if it's possible to play some remote video via rstp, rtmp protocol with links (rtsp://52.58.174.38/vod/sample.mp4, rtmp://52.58.174.38/vod/mp4:sample.mp4). Ohers remote file I'll like to play is MPEG DASH file (http://52.58.174.38/vod/mp4:sample.mp4/manifest.mpd). Brief I want play VOD streaming in an android application build with Nativescript.

finished event not implemented in iOS?

Might be an oversight on my behalf, but I don't think the finished event is plugged in for iOS.
I see code implemented in it for Android, and can confirm it works properly there. I don't see anything written for iOS, and also cannot get it to fire in iOS at all.

Feel free to close this issue if I've clearly overlooked something.

VideoPlayer with ScrollView

Hello,

I use nativescript-videoplayer in ScrollView. When I scroll up or scroll down, video frame have a problem, it have black frame in bottom of video.
screen shot 2016-11-03 at 3 51 53 pm

Thanks.

How to display center aspectFill

I am trying to display rectangle video in square frame.
I want video to centered fill all frame but not squashed.

What I want to display something like this

-------------------------
|    |             |    |
|    |             |    |
|    |             |    |
|    |             |    |
|    |             |    |
|    |             |    |
-------------------------
 / \        / \
  |          | 
  |          | 
  |         frame 
  |     
video

But now i only can get something like this

     --------------- 
     |             | <- frame
     |-------------| 
     |             | <- video
     |             | 
     |-------------| 
     |             | 
     --------------- 

I tried this but did not work

<VideoPlayer
      stretch="aspectFill"
      verticalAlignment="center"
      [src]="videoLink"
      horizontalAlignment="center"></VideoPlayer>

Also tried to use callback and calculate width depending on video width like this.

.html
    <VideoPlayer
      [left]="playerOffsetX"
      [top]="playerOffsetY"
      stretch="aspectFill"
      verticalAlignment="center"
      horizontalAlignment="center"
      #videoPlayer
      [src]="videoLink"
      loaded="videoplayerLoaded"
      finished="videoFinished"
      autoplay="true"
      controls="true"
      [width]="playerWidth"
      [height]="playerHeight"
      (loadingComplete)="playerCallback($event)"
    ></VideoPlayer>


.ts
  playerCallback(e: VideoSource){
    let player = <Video>this.videoPlayer.nativeElement;
    CustomTracer.log("asdfasdfasdfasdfasdfasdfasdf", player.width, player.android, player.android.src)
    var vidSource = fromFile(this.videoLink)
    CustomTracer.log("asdfasdfasdfasdfasdfasdfasdf", e.width)
    // this.playerWidth = player.android.videoSource.width
    // this.playerHeight = player.android.videoSource.height
    // this.playerOffsetX = 10
    // this.playerOffsetY = 40
  }

Callback is called, but player.android.videoSource and e.width are undefined.
console.log(e) gives me circular JSON error. So I can't see content of e

Any suggesstion?

Feature Request - Add option to overlay Android controls on VideoView

Need to add an optional attribute to overlay the Media Controls on top of the Android VideoView. Could probably use this as the default and make it an optional attribute to not position it on top of the view. Attribute such as android:anchorControls="false" which would not anchor the controls.

Can't play this video message

I tried with s3 url and not works, a local file neither. I prove another url and still not works. can u help me? thanks.

iOS is not destroying properly

After doing some extensive testing it looks like there is a hard limit of 18 AVPlayers that cant be initialised. Once this limit is hit, the vide will stop playing and results in the grey screen with a cross line on Play icon.

Despite triggering the destroy method, this still occurs. Have tried a few things on destroy but still resulting in the same issue.

doc: Documentation of using this plugin with angular 2

I'm using nativescript with angular for my next application. It has a lot of videos to play and I tried to integrate this plugin, but couldn't get it to work. I'm pretty sure that there might be some changes in the syntax when we're using this with angular. I would like to help out, in any way I can, to get this plugin documented and working great with nativescript and angular projects. Let me know how I can be of help.

Video Not Loading in Angular 2 and Nativescript

I have added the code to my template, but it is not showing in the app. Do you have to reference the code in the template differently in an Angular 2 and Nativescript application?

Template Code:

<StackLayout>
    <Label text="Grand Hall"></Label>
    <VideoPlayer:Video #nativeVideoPlayer controls="true" autoplay="true" height="280" src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />
</StackLayout>

Component Code:

import { Component, ElementRef, ViewChild } from "@angular/core";
import { Video } from 'nativescript-videoplayer';


@Component({
    selector: "grandhall",
    templateUrl: "pages/grandhall/grandhall.html",
    styleUrls: ["pages/grandhall/grandhall-common.css", "pages/grandhall/grandhall.css"]
})

export class GrandHallComponent {
    @ViewChild("nativeVideoPlayer") nativeVideoPlayer: ElementRef;
}   

Videoplayer resizes in a weird way on screen orientation change

Hi,

not sure if I'm doing something wrong, but the videoplayer is misbehaving on screen orientations.

videoplayer.xml:
`

<StackLayout id="player-container" backgroundColor="black">

    <VideoPlayer:Video id="player" controls="false" loop="false" autoplay="true" src="~/videos/test.mp4" />

</StackLayout>

`

This displays the video nicely centered vertically, but when the screen orientation changes, it seems to keep the same padding above the videoplayer, which makes the videoplayer height smaller instead of using the entire screen height.
This also makes the aspect ratio very warped.

illustration

And ideas what is going wrong?

Can not change video-source after downloading from server (localFile works)

Can not change video-source after downloading from server (localFile works)

component.html

<VideoPlayer
      [width]="playerWidth"
      [height]="playerHeight"
      [left]="playerOffsetX"
      [top]="playerOffsetY"
      (loadingComplete)="playerCallback($event)"

      #videoPlayer
      id="videoPlayer"
      controls="true"
      loop="true"
      autoplay="true"
      [src]="videoLink"
      row="0"
      colSpan="2"></VideoPlayer>

component.ts

  ngOnInit() {
     ...
           this.videoService.downloadVideoById(s.video.hashId, s.video.link)
            .then(vs => {
              CustomTracer.log("videoSource is : ", vs.path);
              // TODO: This does not invoke this.player.android.setVideoPath(vs.path)
              this.videoLink = vs.path;
            }, e => console.error("videoSource error1 : ", e))
            .catch(e => {
              CustomTracer.error("videoSource error : ", e)
              console.log(e)
            });
  }

  playerCallback(args: EventData){
    console.log("from playerCallback")
  }
video.service.ts

  downloadVideoById(videoHashId:string, videoLink:string):Promise<fs.File> {
    var tempFolder = fs.knownFolders.temp();
    var folderPath = fs.path.join(tempFolder.path, this.videoFolder);
    if (!fs.Folder.exists(folderPath)) {
      CustomTracer.info(folderPath + " : folder does not exist. Creating")
      var folder = tempFolder.getFolder(this.videoFolder);
    }
    // var folder     = fs.Folder.fromPath(folderPath);
    var filepath = fs.path.join(folderPath, videoHashId + ".mp4");
    if (fs.File.exists(filepath)) {
      CustomTracer.log("video file  exist")
      // return new Promise(function (resolve, reject) {    <------ If I comment in this 3 lines video plays second time i open page.
      //   var file = fs.File.fromPath(filepath);
      //   resolve(file);
      // })
    }
    CustomTracer.info("Video download request : " + videoHashId);
    return http.getFile(videoLink, filepath)                      <------without above 3 line of local file code video never plays. I can confirm video file is downloaded and created.

  }

with local file cache it prints from playerCallback

Without local file cache It never prints from playerCallback

Issue with install, '0' of undefined

Hello brad,

I was just attempting to install this plugin (using tns plugin add nativescript-videoplayer). I was given this error on install Cannot read property '0' of undefined
I also was given this yellow warning even tho i have zone isntalled (idk if this is related or not) The package [email protected] does not satisfy its siblings' peerDependencies requir ements!
Any ideas on how to fix this?

Thanks!

timeupdate event

Hi Martin,
Is it possible to use somthing like timeupdate event in videojs player : [http://docs.videojs.com/docs/api/player.html#Eventstimeupdate]

NativeScript Video Player is not working

From @narender56 on February 1, 2017 11:23

Hello everyone,

I have to stream a video lively, so i have used the nativescript-videoplayer module, but i've clone the project and initiated tns run, but it throwing following error.Can anyone please tell me how to resolve the error?

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.demo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed

Error: Building UI from XML. @file:///app/main-page.xml:16:9

Module '/data/data/org.nativescript.demo/files/app/nativescript-videoplayer' not found for element 'nativescript-videoplayer:Video'.
com.tns.NativeScriptException: Failed to find module with absolute path: "/data/data/org.nativescript.demo/files/app/nativescript-videoplayer".
com.tns.Module.resolvePathHelper(Module.java:220)
com.tns.Module.resolvePath(Module.java:60)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:862)
com.tns.Runtime.callJSMethodImpl(Runtime.java:727)
com.tns.Runtime.callJSMethod(Runtime.java:713)
com.tns.Runtime.callJSMethod(Runtime.java:694)
com.tns.Runtime.callJSMethod(Runtime.java:684)
com.tns.NativeScriptActivity.onCreate(NativeScriptActivi

Copied from original issue: NativeScript/NativeScript#3551

Can't get getCurrentTime after the 1.0.3 version update

Hi,
i am using nativescript-angular 2 after updating the plugin i am started to not get getCurrentTime from the api and no error on the console everything else work perfectly. i mean i can play/pause or seek without any problem.

Cannot open local file

I download a file, and save it in the path '/Users/wos/Library/Developer/CoreSimulator/Devices/F5C257D2-62F8-4E14-BC43-5BD659F501A8/data/Containers/Data/Application/90044531-7176-439E-AA88-768721406A9A/Documents/burpees.mp4'.

The videoplayer can not play this.

[iOS] Cannot change `controls` property after init

I have this famous iOS issue 'Unable to simultaneously satisfy constraints' when using the VideoPlayer. I know this is a bug in the AVPlayer, but I cannot seem to get around it.

The way around it is to disable the showsPlaybackControls before attaching the video-source. Then enable it. I can see that you have implemented this in the plugin-code for ios. But the error is still present.

I get the video-source url from a service, so I change the controls property to true after the binding is set. But even then the controls are not shown, which tells med that perhaps controls property cannot be set after init?

I have also tried setting controls="true" in the xml, but then the above error appears when going fullscreen video.

stop / pause playback

Hi All,

I'm very much a noob with NS, and I now have this fantastic plugin up and running nicely, however I need to be able to stop playback programatically.

Can someone please advise how this is achieved ? A quick google shows the android method on VideoView is .stop(), whilst with IOS AVPlayer it is simply .pause()

However I can't seem to find an obvious way to invoke these methods. I'd be most appreciative if someone could point me in the right direction please.

Compilation failed on ios

When I'm running tns build ios .. compilation failed and show this error messages below:

Analyzing dependencies
Downloading dependencies
Using GoogleMaps (1.12.3)
Using IQKeyboardManager (4.0.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total
pods installed.
Processing node_modules failed. Exception: Pod install command failed. Error output: 2016-03-24 02:02:41.086 ruby[2692:42624] Failed to save project: "/Volumes/Data/<ProjectDir>/platforms/ios/Pods/Pods.xcodeproj"

I thought there is a problem with my internet connection so the pod can't be installed but after check my connection, everything is okay

And I'm using:

El Capitan 10.11.3
XCode 7.2

Any clue?

Can't stop the video Angular2+

I have a video on a page :
*html
<VideoPlayer #videoPlayer src="{{ videoSrc }}" controls="true" loop="false" finished="{{ completed }}" autoplay="true" height="200"></VideoPlayer>

*component

registerElement("VideoPlayer", () => require("nativescript-videoplayer").Video);```

When I am navigating between my views and come back to the page with the videoplayer the video plays again and again and again... I want to be able to stop the video (destroy the video).

`"nativescript-videoplayer": "^2.4.0",`

But I can't get a reference to the videoPlayer. I tried it with @ViewChild but no luck. 

Any thoughts plz?

error TS2307: Cannot find module './videoplayer'.

I'm not sure if it is related to the error "Cannot find module './video-source/video-source'".

When I tried running my app i got the following error:

app/pages/video/videoplayerpage.ts(6,9): error TS2305: Module '"C:/sampleapp/node_modules/nativescript-videoplayer/index"' has no exported member 'Video'.

/node_modules/nativescript-videoplayer/index.d.ts(1,15): error TS2307: Cannot find module './videoplayer'.

Can't play the video if i set src inside the subscribe

Hi,
in my app i need to get video informations (video path etc) from my server and with that informations i want to play the video.But even though i can set the video src in the subcribe part of the code video dont play and player act as there is no src setted (even if i call outside functions inside of subcribe code blok to set src it doesnt work).but if i set src outside of the subcribe code block it work perfectlly.

ngOnInit() {
this._videoPlayer =

        this._video_item=loadedvideo as Video_Item;
    this._videoPlayer.src=Config.hostUrl+this._video_item.path;<<if i set src here even if i see that src was set video doesnt play>> 
       if(this._video_item.slides.length>0)
        {
            this.slide_url=this._video_item.slides[0].pic_url;
        }
        this.index_list=this._video_item.indexes;
        this.trackVideoCurrentPosition();

        console.log(" toplam indexes : "+this._video_item.indexes.length);
        console.log(" toplam slides : "+this._video_item.slides.length);



        console.log(" video url : "+Config.hostUrl+this._video_item.path);
        },
        (error) => alert("Hata."+error)
            );



}

thanks.

Video iOS run in background

Hello,

I have a question about your plugin. In iOS, I use video player in ListView, when I scroll ListView to other item, ListView auto remove video player, and when I scroll in it again ListView generate new video player. And the old video player still play in background. How to turn off video player run in background when scroll to other item in ListView?

Thanks.

Add event for currentTimeUpdated

We should have an event that gets emitted when the _playbackTimeObserver interval ticks. This event would eliminate the need for a second interval to track the property.

destroy public method needed

Navigating back and forth from pages with a video player within them can cause a memory leak.
A destroy method, which can be called on navigatedFrom within an app's page would help.

Here's an example of one for iOS (which will also remove the loop callback)
Again, sorry for JS only version.

Video.prototype.destroy = function() {

    if (this.finishedCallback) {
        var nsCenter = NSNotificationCenter.defaultCenter();
        nsCenter.removeObserverNameObject(AVPlayerItemDidPlayToEndTimeNotification, null, null);
    }

    this._player.pause();
    this._player = null; //de-allocates the AVPlayer
    this._playerController = null;

};

Demo fails to run

Errors:

app/main-page.ts(22,51): error TS2345: Argument of type 'View' is not assignable to parameter of type 'Video'.
  Property 'src' is missing in type 'View'.

node_modules/nativescript-videoplayer/index.d.ts(1,15): error TS2306: File '/Users/vchimev/Work/git/nativescript-videoplayer/demo/node_modules/nativescript-videoplayer/videoplayer.d.ts' is not a module.

node_modules/nativescript-videoplayer/videoplayer.d.ts(9,5): error TS2439: Import or export declaration in an ambient module declaration cannot reference module through relative module name.

node_modules/nativescript-videoplayer/videoplayer.d.ts(9,34): error TS2307: Cannot find module './video-source/video-source'.

Output:

Successfully deployed on device with identifier 'E2B61754-93E2-4906-B740-3E9D196EA62B'.
Aug 16 14:32:15 mcsofvchimev backboardd[6449]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev backboardd[6449]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev backboardd[6449]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev backboardd[6449]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev backboardd[6449]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev demo[6640]: assertion failed: 15G31 13E230: libxpc.dylib + 57882 [66C28065-C9DB-3C8E-926F-5A40210A6D1B]: 0x7d
Aug 16 14:32:15 mcsofvchimev demo[6640]: SecTaskLoadEntitlements failed error=22 cs_flags=200, task->pid_self=6640
Aug 16 14:32:15 mcsofvchimev demo[6640]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:15 mcsofvchimev demo[6640]: SecTaskLoadEntitlements failed error=22 cs_flags=200, task->pid_self=6640
Aug 16 14:32:15 mcsofvchimev demo[6640]: SecTaskCopyDebugDescription: demo[6640]
Aug 16 14:32:16 mcsofvchimev demo[6640]: 1   0x10ecd0709 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
Aug 16 14:32:16 mcsofvchimev demo[6640]: 2   0x10f33b01e ffi_closure_unix64_inner
Aug 16 14:32:16 mcsofvchimev demo[6640]: 3   0x10f33b9d2 ffi_closure_unix64
Aug 16 14:32:16 mcsofvchimev demo[6640]: 4   0x1120e8074 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
Aug 16 14:32:16 mcsofvchimev demo[6640]: 5   0x1120e7c21 __CFRunLoopDoTimer
Aug 16 14:32:16 mcsofvchimev demo[6640]: 6   0x1120a9b11 __CFRunLoopRun
Aug 16 14:32:16 mcsofvchimev demo[6640]: 7   0x1120a90f8 CFRunLoopRunSpecific
Aug 16 14:32:16 mcsofvchimev demo[6640]: 8   0x113eeaad2 GSEventRunModal
Aug 16 14:32:16 mcsofvchimev demo[6640]: 9   0x10fd86f09 UIApplicationMain
Aug 16 14:32:16 mcsofvchimev demo[6640]: 10  0x10f33b82d ffi_call_unix64
Aug 16 14:32:16 mcsofvchimev demo[6640]: 11  0x11a3bb350
Aug 16 14:32:16 mcsofvchimev demo[6640]: file:///app/main-view-model.js:83:71: JS ERROR TypeError: _this._videoPlayer.getCurrentTime is not a function. (In '_this._videoPlayer.getCurrentTime()', '_this._videoPlayer.getCurrentTime' is 0)
Aug 16 14:32:16 mcsofvchimev com.apple.CoreSimulator.SimDevice.E2B61754-93E2-4906-B740-3E9D196EA62B.launchd_sim[6432] (UIKitApplication:org.nativescript.videoplayer[0x2e66][6640]): Service exited due to signal: Segmentation fault: 11

Listview video reloading

Hello, When using in Listview and scrolling, each video player frame reloads its source. It happens as soon as you scroll away from the listview item and come back to it. It results in some lag or delay when you scroll.
After scrolling up and down many times some video player instances are loosing their sources.
Is there a way to prevent the video instance from reloading multiple times once it has loaded first time ?
May be you should check in the source if the url was loaded before enabling the reload ..
thanks.

TS-NG2: Cannot find module './video-source/video-source'.

I was following the demo app, and I am getting this error when trying to get hold of the player -

myPause(e:any) {
let videoPlayer = topmost().getViewById('nativeVideoPlayer');
this.doPause(videoPlayer)
}
doPause(videoPlayer:Video) {
videoPlayer.pause();
}

And the error I am getting is -

Found peer TypeScript 1.8.10
app/components/tabs/tab3/tab3.component.ts(27,22): error TS2345: Argument of type 'View' is not assignable to parameter of type 'Video'.
Property 'src' is missing in type 'View'.

node_modules/nativescript-videoplayer/index.d.ts(1,15): error TS2306: File '/Users/jahid/Development/temp/native_script/ns-learning/node_modules/nativescript-videoplayer/videoplayer.d.ts' is not a module.

node_modules/nativescript-videoplayer/videoplayer.d.ts(9,5): error TS2439: Import or export declaration in an ambient module declaration cannot reference module through relative module name.

node_modules/nativescript-videoplayer/videoplayer.d.ts(9,34): error TS2307: Cannot find module './video-source/video-source'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.