Skip to content

Commit daf430d

Browse files
committed
fix up demo, ts errors, definition
1 parent f5c076b commit daf430d

13 files changed

+994
-787
lines changed

demo/app/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import * as application from 'application';
2-
application.start({ moduleName: 'main-page' });
1+
import * as application from "tns-core-modules/application";
2+
application.start({ moduleName: "main-page" });

demo/app/main-page.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import { Page } from 'ui/page';
2-
import { EventData } from 'data/observable';
3-
import { HelloWorldModel } from './main-view-model';
4-
import { isAndroid, device } from "platform";
5-
import { Color } from "color";
6-
import { topmost } from "ui/frame";
7-
import { android } from "application";
8-
import { Video } from 'nativescript-videoplayer';
1+
import { Page } from "tns-core-modules/ui/page";
2+
import { EventData } from "tns-core-modules/data/observable";
3+
import { HelloWorldModel } from "./main-view-model";
4+
import { isAndroid, device } from "tns-core-modules/platform";
5+
import { Color } from "tns-core-modules/color";
6+
import { topmost } from "tns-core-modules/ui/frame";
7+
import { android } from "tns-core-modules/application";
98

109
// Event handler for Page "loaded" event attached in main-page.xml
1110
export function pageLoaded(args: EventData) {
12-
// Get the event sender
13-
let page = <Page>args.object;
14-
page.bindingContext = new HelloWorldModel(page);
11+
// Get the event sender
12+
let page = <Page>args.object;
13+
page.bindingContext = new HelloWorldModel(page);
1514

16-
if (isAndroid && device.sdkVersion >= "21") {
17-
let window = android.startActivity.getWindow();
18-
window.setStatusBarColor(new Color("#d32f2f").android);
19-
}
20-
21-
}
15+
if (isAndroid && device.sdkVersion >= "21") {
16+
let window = android.startActivity.getWindow();
17+
window.setStatusBarColor(new Color("#d32f2f").android);
18+
}
19+
}

demo/app/main-page.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<Button text="Go to 30 seconds" width="33%" tap="{{ goToTime }}" />
2929
</StackLayout>
3030
<Button text="Animate" width="33%" tap="{{ animate }}"/>
31+
<Button text="Programmatic Video Player" tap="{{ createVideoPlayer }}" />
32+
<StackLayout id="emptyStack"></StackLayout>
3133
</StackLayout>
3234
</ScrollView>
3335
</Page>

demo/app/main-view-model.ts

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { Observable } from "data/observable";
2-
import { Page } from "ui/page";
3-
import { isAndroid } from "platform";
4-
import { setInterval } from "timer";
1+
import { Observable } from "tns-core-modules/data/observable";
2+
import { Page } from "tns-core-modules/ui/page";
3+
import { topmost } from "tns-core-modules/ui/frame";
4+
import { isAndroid } from "tns-core-modules/platform";
5+
import { setInterval } from "tns-core-modules/timer";
6+
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
57
import { Video } from "nativescript-videoplayer";
68

79
export class HelloWorldModel extends Observable {
@@ -36,7 +38,6 @@ export class HelloWorldModel extends Observable {
3638
this._videoPlayer.pause();
3739
}
3840

39-
4041
/**
4142
* Play the video
4243
*/
@@ -45,7 +46,6 @@ export class HelloWorldModel extends Observable {
4546
this.completed = false;
4647
}
4748

48-
4949
/**
5050
* Stop the video player
5151
*/
@@ -55,7 +55,6 @@ export class HelloWorldModel extends Observable {
5555
}
5656
}
5757

58-
5958
/**
6059
* Get the video duration
6160
*/
@@ -65,7 +64,6 @@ export class HelloWorldModel extends Observable {
6564
this.set("videoDuration", videoDuration);
6665
}
6766

68-
6967
/**
7068
* Go to 30 seconds
7169
*/
@@ -77,43 +75,55 @@ export class HelloWorldModel extends Observable {
7775
}
7876
}
7977

80-
8178
public animate() {
8279
console.log("Animation");
8380

8481
const enums = require("ui/enums");
85-
this._videoPlayer.animate({
86-
rotate: 360,
87-
duration: 3000,
88-
curve: enums.AnimationCurve.spring
89-
}).then(() => {
90-
return this._videoPlayer.animate({
91-
rotate: 0,
92-
duration: 3000,
93-
curve: enums.AnimationCurve.spring
94-
});
95-
}).then(() => {
96-
return this._videoPlayer.animate({
97-
scale: { x: .5, y: .5 },
98-
duration: 1000,
99-
curve: enums.AnimationCurve.spring
100-
});
101-
102-
}).then(() => {
103-
return this._videoPlayer.animate({
104-
scale: { x: 1.5, y: 1.5 },
105-
duration: 3000,
106-
curve: enums.AnimationCurve.spring
107-
});
108-
}).then(() => {
109-
return this._videoPlayer.animate({
110-
scale: { x: 1.0, y: 1.0 },
82+
this._videoPlayer
83+
.animate({
84+
rotate: 360,
11185
duration: 3000,
11286
curve: enums.AnimationCurve.spring
87+
})
88+
.then(() => {
89+
return this._videoPlayer.animate({
90+
rotate: 0,
91+
duration: 3000,
92+
curve: enums.AnimationCurve.spring
93+
});
94+
})
95+
.then(() => {
96+
return this._videoPlayer.animate({
97+
scale: { x: 0.5, y: 0.5 },
98+
duration: 1000,
99+
curve: enums.AnimationCurve.spring
100+
});
101+
})
102+
.then(() => {
103+
return this._videoPlayer.animate({
104+
scale: { x: 1.5, y: 1.5 },
105+
duration: 3000,
106+
curve: enums.AnimationCurve.spring
107+
});
108+
})
109+
.then(() => {
110+
return this._videoPlayer.animate({
111+
scale: { x: 1.0, y: 1.0 },
112+
duration: 3000,
113+
curve: enums.AnimationCurve.spring
114+
});
113115
});
116+
}
114117

115-
});
116-
118+
public createVideoPlayer() {
119+
const video = new Video();
120+
video.height = 200;
121+
video.width = 175;
122+
video.src = "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
123+
video.controls = false;
124+
video.autoplay = true;
125+
const stack = topmost().getViewById("emptyStack") as StackLayout;
126+
stack.addChild(video);
117127
}
118128

119129
public muteVideo() {
@@ -124,7 +134,6 @@ export class HelloWorldModel extends Observable {
124134
this._videoPlayer.mute(false);
125135
}
126136

127-
128137
/**
129138
* Get the video current time
130139
*/
@@ -137,21 +146,18 @@ export class HelloWorldModel extends Observable {
137146
}
138147
}
139148

140-
141-
142149
/**
143150
* Change the video src property
144151
*/
145152
public changeVideoSource() {
146153
if (this.videoSrc === "~/videos/small.mp4") {
147-
this._videoPlayer.src = "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
154+
this._videoPlayer.src =
155+
"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
148156
} else {
149157
this._videoPlayer.src = "~/videos/small.mp4";
150158
}
151159
}
152160

153-
154-
155161
private trackVideoCurrentPosition(): number {
156162
let trackInterval = setInterval(() => {
157163
let x, y;
@@ -166,8 +172,5 @@ export class HelloWorldModel extends Observable {
166172
this.set("videoDuration", y);
167173
}, 200);
168174
return trackInterval;
169-
170175
}
171-
172-
173-
}
176+
}

demo/app/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2+
"main": "app.js",
23
"nativescript": {
34
"id": "org.nativescript.demo"
45
},
56
"dependencies": {
6-
"nativescript-theme-core": "~1.0.2",
7+
"nativescript-theme-core": "~1.0.2",
78
"nativescript-videoplayer": "..",
89
"tns-core-modules": "^3.0.0"
910
},
1011
"devDependencies": {
11-
"nativescript-dev-typescript": "~0.4.0",
12-
"typescript": "~2.2.1"
12+
"nativescript-dev-typescript": "~0.4.0",
13+
"typescript": "~2.2.1"
1314
}
14-
}
15+
}

demo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
"version": "3.0.0"
66
},
77
"tns-android": {
8-
"version": "3.0.0"
8+
"version": "3.0.1"
99
}
1010
},
1111
"dependencies": {
1212
"nativescript-theme-core": "~1.0.2",
13-
"nativescript-videoplayer": "file:///Users/blake/Documents/nativescript-videoplayer",
13+
"nativescript-videoplayer": "file:..",
1414
"tns-core-modules": "^3.0.0"
1515
},
1616
"devDependencies": {
1717
"babel-traverse": "6.24.1",
1818
"babel-types": "6.24.1",
1919
"babylon": "6.17.0",
2020
"lazy": "1.0.11",
21-
"nativescript-dev-typescript": "~0.4.0",
22-
"typescript": "~2.2.1"
21+
"nativescript-dev-typescript": "~0.4.5",
22+
"typescript": "^2.2.2"
2323
}
2424
}

demo/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
"experimentalDecorators": true,
66
"emitDecoratorMetadata": true,
77
"noEmitHelpers": true,
8-
"noEmitOnError": true,
8+
"noEmitOnError": false,
99
"allowJs": false,
10+
"types": [],
1011
"lib": [
1112
"es6",
1213
"dom"
1314
],
15+
"rootDir": ".",
1416
"baseUrl": ".",
1517
"paths": {
1618
"*": [

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "nativescript-videoplayer",
3-
"version": "3.0.7",
3+
"version": "3.0.8",
44
"main": "videoplayer",
5-
"typings": "index.d.ts",
5+
"typings": "videoplayer.d.ts",
66
"description": "A NativeScript plugin that uses the native video players to play local and remote videos.",
77
"nativescript": {
88
"platforms": {
@@ -60,7 +60,7 @@
6060
],
6161
"author": {
6262
"name": "Brad Martin",
63-
"email": "bradmartin0905@gmail.com",
63+
"email": "bradwaynemartin@gmail.com",
6464
"url": "https://github.com/bradmartin"
6565
},
6666
"license": "Apache-2.0",
@@ -76,12 +76,12 @@
7676
"_shasum": "7bdee571649168a79ded1bf63beb6d7b4b9cfa2a",
7777
"_from": "..",
7878
"_resolved": "file:..",
79-
"devDependencies": {
80-
"tns-core-modules": "^3.0.0",
81-
"tns-platform-declarations": "^3.0.0",
82-
"typescript": "^2.2.2"
83-
},
8479
"peerDependencies": {
8580
"tns-core-modules": "^3.0.0"
81+
},
82+
"devDependencies": {
83+
"typescript": "^2.2.2",
84+
"tns-core-modules": "^3.0.0",
85+
"tns-platform-declarations": "3.0.1"
8686
}
8787
}

tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"target": "es5",
5+
"sourceMap": false,
56
"noImplicitAny": false,
67
"removeComments": true,
78
"preserveConstEnums": true,
8-
"sourceMap": false,
99
"declaration": false,
1010
"noLib": false,
1111
"noEmitHelpers": true,
1212
"experimentalDecorators": true,
13-
"noEmitOnError": false,
13+
"noEmitOnError": false,
1414
"lib": [
1515
"es6",
1616
"dom"
1717
],
1818
"baseUrl": ".",
1919
"paths": {
2020
"*": [
21-
"./demo/node_modules/tns-core-modules/*",
22-
"./demo/node_modules/*"
21+
"./node_modules/tns-core-modules/*",
22+
"./node_modules/*"
2323
]
2424
}
2525
},

0 commit comments

Comments
 (0)