├── .gitignore
├── .nocompile
├── LICENSE.md
├── README.md
└── platform
├── androidtv
├── .core.js
├── .manifest
├── device.js
├── dist
│ ├── banner.png
│ └── build.py
└── video.js
├── dune
├── .core.js
├── .manifest
└── device.js
├── hisense
├── .core.js
├── .manifest
├── device.js
└── video.js
├── netcast
├── .core.js
├── .manifest
├── device.js
├── dist
│ ├── icon.png
│ └── lgconfig.xml
└── drmVideo.js
├── operatv
├── .core.js
├── .manifest
└── device.js
├── orsay
├── .core.js
├── .manifest
├── device.js
├── dist
│ ├── bigListIcon.png
│ ├── bigThumbIcon.png
│ ├── config.xml
│ ├── index.html
│ ├── listIcon.png
│ ├── thumbIcon.png
│ └── widget.info
├── samsung-log-server
└── video.js
├── tizen
├── .core.js
├── .manifest
├── device.js
├── dist
│ ├── config.xml
│ ├── icon.png
│ └── index.html
└── video.js
└── webos
├── .core.js
├── .manifest
├── LunaServiceApi.qml
├── device.js
├── dist
├── .directory
├── appinfo.json
├── icon.png
├── index.html
├── preview.png
├── splash.png
└── webOSTVjs-1.1.0
│ ├── LICENSE-2.0.txt
│ ├── webOSTV-dev.js
│ └── webOSTV.js
└── video.js
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.swo
3 |
--------------------------------------------------------------------------------
/.nocompile:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/.nocompile
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ## creative commons
2 |
3 | # Attribution-ShareAlike 4.0 International
4 |
5 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
6 |
7 | ### Using Creative Commons Public Licenses
8 |
9 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
10 |
11 | * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
12 |
13 | * __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
14 |
15 | ## Creative Commons Attribution-ShareAlike 4.0 International Public License
16 |
17 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
18 |
19 | ### Section 1 – Definitions.
20 |
21 | a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
22 |
23 | b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
24 |
25 | c. __BY-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
26 |
27 | d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
28 |
29 | e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
30 |
31 | f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
32 |
33 | g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
34 |
35 | h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
36 |
37 | i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
38 |
39 | j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
40 |
41 | k. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
42 |
43 | l. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
44 |
45 | m. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
46 |
47 | ### Section 2 – Scope.
48 |
49 | a. ___License grant.___
50 |
51 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
52 |
53 | A. reproduce and Share the Licensed Material, in whole or in part; and
54 |
55 | B. produce, reproduce, and Share Adapted Material.
56 |
57 | 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
58 |
59 | 3. __Term.__ The term of this Public License is specified in Section 6(a).
60 |
61 | 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
62 |
63 | 5. __Downstream recipients.__
64 |
65 | A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
66 |
67 | B. __Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
68 |
69 | C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
70 |
71 | 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
72 |
73 | b. ___Other rights.___
74 |
75 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
76 |
77 | 2. Patent and trademark rights are not licensed under this Public License.
78 |
79 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
80 |
81 | ### Section 3 – License Conditions.
82 |
83 | Your exercise of the Licensed Rights is expressly made subject to the following conditions.
84 |
85 | a. ___Attribution.___
86 |
87 | 1. If You Share the Licensed Material (including in modified form), You must:
88 |
89 | A. retain the following if it is supplied by the Licensor with the Licensed Material:
90 |
91 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
92 |
93 | ii. a copyright notice;
94 |
95 | iii. a notice that refers to this Public License;
96 |
97 | iv. a notice that refers to the disclaimer of warranties;
98 |
99 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
100 |
101 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
102 |
103 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
104 |
105 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
106 |
107 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
108 |
109 | b. ___ShareAlike.___
110 |
111 | In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
112 |
113 | 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
114 |
115 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
116 |
117 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
118 |
119 | ### Section 4 – Sui Generis Database Rights.
120 |
121 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
122 |
123 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
124 |
125 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
126 |
127 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
128 |
129 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
130 |
131 | ### Section 5 – Disclaimer of Warranties and Limitation of Liability.
132 |
133 | a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
134 |
135 | b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
136 |
137 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
138 |
139 | ### Section 6 – Term and Termination.
140 |
141 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
142 |
143 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
144 |
145 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
146 |
147 | 2. upon express reinstatement by the Licensor.
148 |
149 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
150 |
151 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
152 |
153 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
154 |
155 | ### Section 7 – Other Terms and Conditions.
156 |
157 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
158 |
159 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
160 |
161 | ### Section 8 – Interpretation.
162 |
163 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
164 |
165 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
166 |
167 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
168 |
169 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
170 |
171 | > Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
172 | >
173 | > Creative Commons may be contacted at creativecommons.org.
174 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PureQML TV plugin
2 | This plugin allow you to build [PureQML](https://pureqml.com/) apps for SmartTV platforms
3 |
4 | # Platforms
5 |
6 |
AndroidTV
7 |
Hisense
8 |
LG NetCast
9 |
LG WebOS
10 |
OperaTV
11 |
Samsung Orsay
12 |
Samsung Tizen
13 |
14 |
15 | # Install
16 | Just place `qmlcore-tv` into your PureQML project root and you will able to build your app for any corresponded platform
17 |
18 | # Build
19 | To build an app for specific platform use this command:
20 |
21 | `./qmlcore/build -p androidtv|hisense|netcast|webos|opera|orsay|tizen`
22 |
23 | # Licence
24 | [Creative Commons Attribution Share Alike 4.0](https://github.com/pureqml/qmlcore-tv/blob/master/LICENSE.md)
25 |
26 | # Adding New Platform
27 |
28 | Platform is pretty much similar to any qml package you may have, just a directory with .manifest file in it. Platforms have some additional handling in build command (-p/--platform switch), but that's pretty much it. All dependencies are processed as anywhere else, platform code may have dist/ folder with additional files: own components and javascript modules, etc.
29 |
30 | ## Name
31 | Pick a name relevant to platform or platform family. Ideally internal name, recognisable in professional community. Create platform/ directory. A few names are webos, orsay, tizen, we prefer lowercase kebab notation.
32 |
33 | ## Manifest
34 | Platform manifest is just an ordinary manifests, and they may inherit some addition base platform, e.g. "video.html5" or "html5", and/or override some parent properties, for instance, strict mode. Consider the following example:
35 | ```
36 | {
37 | "requires": ["video.html5", "video.shaka"],
38 | "templates": ["*.html", "appinfo.json"],
39 | "strict": false
40 | }
41 | ```
42 |
43 | This manifest imports video backends from generic html5 and Shaka, and also pass all .html and appinfo.json file to templater, so values from the manifest may override some application properties, like name, author, anything from manifest really.
44 |
45 | ## .core.js
46 |
47 | This file is added really early in resulting js, if specific platform was activated. You may even override log function in it. Normally platforms declare their own key mapping if any, and/or some specific core functions, like close application or handling back button. See platform/<name>/.core.js as a good example how to do it.
48 |
49 | ## dist/*
50 |
51 | Content of this folder has been installed into resulting application directory, with template variable replacement if required by "templates" manifest property.
52 |
53 | ## Anything else
54 |
55 | Anything else goes like normal package into "\_globals.platform.<name>", so you can put additional qml components, include javascript modules, pretty much like anywhere else where .manifest is present.
56 |
57 | If you have any questions feel free to drop us an email, or seek telegram/gitter support on our site: https://pureqml.com
58 |
--------------------------------------------------------------------------------
/platform/androidtv/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__videoBackends.androidtv = function() { return _globals.androidtv.video }
2 | _globals.core.__deviceBackend = function() { return _globals.androidtv.device }
3 |
4 | exports.core.device = 1
5 |
6 | var fitToScreen = function() {
7 | var width = window.$manifest$resolutionWidth
8 | var height = window.$manifest$resolutionHeight
9 |
10 | if (height) {
11 | window.cordovaExecCall("setSize", [width, height],
12 | function() { log("SetSize", width, height) },
13 | function(err) { log("Failed to set size") }
14 | )
15 | } else {
16 | window.cordovaExecCall("ftiToScreen", [],
17 | function() { log("Fit to screen") },
18 | function(err) { log("Failed to fit screen") }
19 | )
20 | }
21 | }
22 |
23 | window.cordovaExecCall = function(name, args, callback, error) {
24 | log("cordovaExecCall", name, "args", args)
25 | if (window.cordova) {
26 | window.cordova.exec(callback, error, "AndroidTV", name, args);
27 | } else {
28 | log("Cordova undefined error")
29 | error()
30 | }
31 | }
32 |
33 | document.addEventListener("deviceready", onDeviceReady, false);
34 | function onDeviceReady() {
35 | console.log("androidtv device ready")
36 | _globals._context.system.vendor = device.manufacturer
37 | fitToScreen()
38 | }
39 |
40 | document.addEventListener("click", handler, true);
41 | function handler(e){
42 | e.stopPropagation();
43 | e.preventDefault();
44 | }
45 |
46 | log("AndroidTV initialized")
47 |
--------------------------------------------------------------------------------
/platform/androidtv/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "requires": ["android", "html5"],
3 | "templates": ["*.html", "config.xml", "build.py"],
4 | "strict": false
5 | }
6 |
--------------------------------------------------------------------------------
/platform/androidtv/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | function onDeviceReady() {
3 | ui.deviceId = device.uuid
4 | ui.modelName = device.model
5 | ui.firmware = device.version
6 | }
7 | ui._context.document.on('deviceready', onDeviceReady);
8 | }
9 |
10 | exports.createDevice = function(ui) {
11 | return new Device(ui)
12 | }
13 |
14 | exports.Device = Device
15 |
--------------------------------------------------------------------------------
/platform/androidtv/dist/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/androidtv/dist/banner.png
--------------------------------------------------------------------------------
/platform/androidtv/dist/build.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 |
3 | import argparse
4 | import os
5 |
6 |
7 | def build(app, title, release):
8 | os.system('rm -rf %s' %app)
9 | res = os.system('cordova create %s com.%s.app %s' %(app, app, title))
10 | if res != 0:
11 | print "Failed to create android app"
12 | return
13 | os.system('rsync -a ./ %s/www --exclude=%s ' %(app,app))
14 | os.system('cp androidIcon.png %s' %(app))
15 | os.system('cp config.xml %s' %(app))
16 | os.chdir(app)
17 | os.system('cordova platform add android')
18 | {% block commands %}{% endblock %}
19 |
20 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-hdpi/.')
21 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-ldpi/.')
22 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-mdpi/.')
23 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-xhdpi/.')
24 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-xxhdpi/.')
25 | os.system('cp ../banner.png ./platforms/android/res/drawable-land-xxxhdpi/.')
26 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-hdpi/.')
27 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-ldpi/.')
28 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-mdpi/.')
29 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-xhdpi/.')
30 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-xxhdpi/.')
31 | os.system('cp ../banner.png ./platforms/android/res/drawable-port-xxxhdpi/.')
32 |
33 | os.system('cordova plugin add https://github.com/comrat/Cordova-Android-TV-Plugin')
34 | os.system('cordova plugin add cordova-plugin-device')
35 | os.system('cordova plugin add https://github.com/comrat/cordova-plugin-exoplayer')
36 | {% block plugins %}{% endblock %}
37 |
38 | if release:
39 | {% if androidBuild %}
40 | build = 'cordova build android --release -- '
41 | os.system(build + '--keystore={{androidBuild.keystore}} --storePassword={{androidBuild.storePassword}} --alias={{androidBuild.alias}} --password={{androidBuild.password}}')
42 | {% else %}
43 | print "Failed to build release apk androidBuild property is undefined"
44 | {% endif %}
45 | else:
46 | os.system('cordova build android')
47 |
48 | os.chdir('..')
49 |
50 |
51 | parser = argparse.ArgumentParser('qmlcore build tool')
52 | parser.add_argument('--app', '-a', help='application name', default="app")
53 | parser.add_argument('--title', '-t', help='application title', default="App")
54 | parser.add_argument('--release', '-r', help='build release apk', default=False)
55 | args = parser.parse_args()
56 |
57 |
58 | res = os.system('cordova --version')
59 | if res == 0:
60 | build(args.app, args.title, args.release)
61 | else:
62 | print 'Install "cordova" first: https://cordova.apache.org/docs/en/latest/guide/cli/'
63 |
--------------------------------------------------------------------------------
/platform/androidtv/video.js:
--------------------------------------------------------------------------------
1 | var Player = function(ui) {
2 | this._ui = ui
3 |
4 | var self = this
5 | ui.setMovie = function(movie) {
6 | self._movie = movie
7 | }.bind(this)
8 |
9 | ui.setControlIcons = function(controls) {
10 | self._controlIcons = controls
11 | }.bind(this)
12 | }
13 |
14 | Player.prototype.setSource = function(value) {
15 | log("set source", value)
16 | if (this._ui.autoPlay)
17 | this.play()
18 | }
19 |
20 | Player.prototype.setOption = function(name, value) {
21 | }
22 |
23 | Player.prototype.setAudioTrack = function(trackId) {
24 | log("setAudioTrack not implemented yet")
25 | }
26 |
27 | Player.prototype.setVideoTrack = function(trackId) {
28 | log("setVideoTrack not implemented yet")
29 | }
30 |
31 | Player.prototype.getAudioTracks = function() {
32 | log("getAudioTracks not implemented yet")
33 | return []
34 | }
35 |
36 | Player.prototype.getVideoTracks = function() {
37 | log("getVideoTracks not implemented yet")
38 | return []
39 | }
40 |
41 | Player.prototype.play = function() {
42 | var ui = this._ui
43 |
44 | var exo = ExoPlayer
45 | if (!this._lifecycleHandled) {
46 | ui._context.document.on("pause", function() { log("Pause activity", exo); exo.close() });
47 | ui._context.document.on("resume", function() { log("Resume to activity") });
48 | this._lifecycleHandled = true
49 | }
50 |
51 | if (ui.paused) {
52 | ExoPlayer.playPause()
53 | return
54 | }
55 |
56 | var self = this
57 | log("Play URL:", ui.source)
58 | ui.ready = false
59 | var movie = this._movie
60 | var controllerConfig = { }
61 |
62 | if (movie)
63 | controllerConfig = {
64 | streamImage: movie.poster,
65 | streamTitle: movie.title,
66 | streamDescription: movie.description,
67 | hideProgress: false,
68 | hidePosition: false,
69 | hideDuration: false,
70 | controlIcons: this._controlIcons || { }
71 | }
72 |
73 | ExoPlayer.show(
74 | {
75 | url: ui.source,
76 | autoPlay: ui.autoPlay,
77 | controller: controllerConfig
78 | },
79 | function(event) {
80 | if (event.eventAction == "ACTION_UP") {
81 | log("EventKeyCode " + event.eventKeycode)
82 | switch (event.eventKeycode) {
83 | case 'KEYCODE_BACK':
84 | case 'KEYCODE_ESCAPE':
85 | exo.close()
86 | break
87 | case 'KEYCODE_DPAD_LEFT':
88 | exo.seekTo(self._position - 30000)
89 | break
90 | case 'KEYCODE_DPAD_RIGHT':
91 | exo.seekTo(self._position + 30000)
92 | break
93 | case 'KEYCODE_DPAD_CENTER':
94 | case 'KEYCODE_MEDIA_PLAY_PAUSE':
95 | if (ui.ready)
96 | exo.playPause()
97 | break
98 | }
99 | ExoPlayer.showController()
100 | }
101 |
102 | exo.getState(
103 | function(e) {
104 | log("Player event", e)
105 | ui.duration = e.duration
106 | var position = parseInt(e.position)
107 | self._position = position
108 | ui.progress = position * 1.0 / 1000
109 | if (ui.duration > 0)
110 | ui.ready = true
111 | var state = e.playbackState
112 | if (state == "STATE_ENDED") {
113 | exo.close()
114 | ui.finished(e.position && e.duration && e.position >= e.duration)
115 | }
116 | },
117 | function(e) { log("Failed to get state", e)}
118 | )
119 | },
120 | function(err) {
121 | console.log("Video error:", err);
122 | ui.error(err)
123 | }
124 | );
125 | }
126 |
127 | Player.prototype.setVisibility = function(visible) {
128 | }
129 |
130 | Player.prototype.pause = function() {
131 | }
132 |
133 | Player.prototype.stop = function() {
134 | }
135 |
136 | Player.prototype.seek = function(delta) {
137 | var exo = ExoPlayer
138 | if (exo)
139 | exo.seekTo(this._position + delta * 1000)
140 | }
141 |
142 | Player.prototype.seekTo = function(tp) {
143 | var exo = ExoPlayer
144 | if (exo)
145 | exo.seekTo(tp * 1000)
146 | }
147 |
148 | Player.prototype.setVolume = function(volume) {
149 | log("Not implemented")
150 | }
151 |
152 | Player.prototype.setMute = function(muted) {
153 | log("Not implemented")
154 | }
155 |
156 | Player.prototype.setLoop = function(loop) {
157 | log("Not implemented")
158 | }
159 |
160 | Player.prototype.setRect = function(l, t, r, b) {
161 | }
162 |
163 | Player.prototype.setBackgroundColor = function(color) {
164 | log("Not implemented")
165 | }
166 |
167 | exports.createPlayer = function(ui) {
168 | return new Player(ui)
169 | }
170 |
171 | exports.probeUrl = function(url) {
172 | return 75
173 | }
174 |
--------------------------------------------------------------------------------
/platform/dune/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__deviceBackend = function() { return _globals.dune.device }
2 |
3 | exports.core.os = "linux"
4 | exports.core.vendor = "dune"
5 | exports.core.device = 1
6 |
7 | document.body.innerHTML = ''
8 | var stb = document.getElementById("duneapi");
9 |
10 | log = function(dummy) {
11 | COPY_ARGS(args, 0)
12 | stb.log("[QML] " + args.join(" "))
13 | }
14 | log("Dune detected")
15 |
16 | if (!stb || !stb.init()) {
17 | log("Dune STB API initialization failed");
18 | return
19 | }
20 |
21 | exports.duneStb = stb
22 |
23 | exports.core.keyCodes = {
24 | 8: 'Back',
25 | 13: 'Select',
26 | 16: 'Shift',
27 | 17: 'Ctrl',
28 | 18: 'LeftAlt',
29 | 38: 'Up',
30 | 27: 'Back',
31 | 37: 'Left',
32 | 39: 'Right',
33 | 40: 'Down',
34 | 48: '0',
35 | 49: '1',
36 | 50: '2',
37 | 51: '3',
38 | 52: '4',
39 | 53: '5',
40 | 54: '6',
41 | 55: '7',
42 | 56: '8',
43 | 57: '9',
44 | 19: 'Pause',
45 | 170: "Search",
46 | 199: "Info",
47 | 403: 'Red',
48 | 404: 'Green',
49 | 405: 'Yellow',
50 | 406: 'Blue',
51 | 178: 'Stop',
52 | 250: 'Play',
53 | 204: 'Rewind',
54 | 205: 'FastForward',
55 | 200: "Menu",
56 | 207: "Audio",
57 | 206: "Subtitle",
58 | 208: "Record"
59 | }
60 |
61 | exports.closeApp = function() {
62 | window.close()
63 | }
64 |
65 | log("Dune initialized")
66 |
--------------------------------------------------------------------------------
/platform/dune/.manifest:
--------------------------------------------------------------------------------
1 | { "requires": ["video.html5"] }
2 |
--------------------------------------------------------------------------------
/platform/dune/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | this._ui = ui
3 | this._stb = document.getElementById("duneapi");
4 | var stb = this._stb
5 | if (!stb) {
6 | log("Dune API STB not defined")
7 | return
8 | }
9 | ui.firmware = stb.getFirmwareVersion()
10 | ui.deviceId = stb.getSerialNumber()
11 | ui.macAddress = stb.getMacAddress()
12 | ui.sdk = stb.getApiVersion()
13 | ui.modelName = stb.getProductId()
14 | }
15 |
16 | exports.createDevice = function(ui) {
17 | return new Device(ui)
18 | }
19 |
20 | exports.Device = Device
21 |
--------------------------------------------------------------------------------
/platform/hisense/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__deviceBackend = function() { return _globals.hisense.device }
2 | _globals.core.__videoBackends.hisense = function() { return _globals.hisense.video }
3 |
4 | log = console.log.bind(console)
5 | log("Hisense detected")
6 | exports.core.os = "hisense"
7 | exports.core.vendor = "Hisense"
8 | exports.core.device = 1
9 |
10 | document.body.innerHTML += ""
11 |
12 | exports.core.keyCodes = {
13 | 8: 'Back',
14 | 13: 'Select',
15 | 16: 'Shift',
16 | 17: 'Ctrl',
17 | 18: 'LeftAlt',
18 | 27: 'Back',
19 | 37: 'Left',
20 | 32: 'Space',
21 | 33: 'PageUp',
22 | 34: 'PageDown',
23 | 38: 'Up',
24 | 39: 'Right',
25 | 40: 'Down',
26 | 48: '0',
27 | 49: '1',
28 | 50: '2',
29 | 51: '3',
30 | 52: '4',
31 | 53: '5',
32 | 54: '6',
33 | 55: '7',
34 | 56: '8',
35 | 57: '9',
36 | 65: 'A',
37 | 66: 'B',
38 | 67: 'C',
39 | 68: 'D',
40 | 69: 'E',
41 | 70: 'F',
42 | 71: 'G',
43 | 72: 'H',
44 | 73: 'I',
45 | 74: 'J',
46 | 75: 'K',
47 | 76: 'L',
48 | 77: 'M',
49 | 78: 'N',
50 | 79: 'O',
51 | 80: 'P',
52 | 81: 'Q',
53 | 82: 'R',
54 | 83: 'S',
55 | 84: 'T',
56 | 85: 'U',
57 | 86: 'V',
58 | 87: 'W',
59 | 88: 'X',
60 | 89: 'Y',
61 | 90: 'Z',
62 | 403: 'Red',
63 | 404: 'Green',
64 | 405: 'Yellow',
65 | 406: 'Blue',
66 | 230: 'RightAlt',
67 | 19: 'Pause',
68 | 413: 'Stop',
69 | 415: 'Play',
70 | 412: 'Rewind',
71 | 417: 'FastForward'
72 | }
73 |
74 | exports.closeApp = function() {
75 | window.close()
76 | }
77 |
78 | document.addEventListener("click", handler, true);
79 | function handler(e){
80 | e.stopPropagation();
81 | e.preventDefault();
82 | }
83 |
84 | log("Hisense initialized")
85 |
--------------------------------------------------------------------------------
/platform/hisense/.manifest:
--------------------------------------------------------------------------------
1 | { "requires": ["video.html5"] }
2 |
--------------------------------------------------------------------------------
/platform/hisense/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | if (window.Hisense_GetDeviceID)
3 | ui.deviceId = window.Hisense_GetDeviceID()
4 | else
5 | ui.deviceId = "hisense_" + Math.random().toString(36).substr(2, 9)
6 |
7 | if (window.Hisense_GetModelName)
8 | ui.modelName = window.Hisense_GetModelName()
9 |
10 | if (window.Hisense_GetFirmWareVersion)
11 | ui.firmware = window.Hisense_GetFirmWareVersion()
12 |
13 | if (window.Hisense_GetCountryCode)
14 | ui.country = window.Hisense_GetCountryCode()
15 |
16 | if (window.Hisense_GetOSVersion)
17 | ui.sdk = window.Hisense_GetOSVersion()
18 |
19 | if (window.Hisense_Get4KSupportState)
20 | ui.supportingUhd = window.Hisense_Get4KSupportState()
21 |
22 | if (window.Hisense_GetSupportForHDR)
23 | ui.supportingHdr = window.Hisense_GetSupportForHDR()
24 |
25 | if (window.Hisense_GetMenuLanguageCode)
26 | ui.language = window.Hisense_GetMenuLanguageCode()
27 | }
28 |
29 | exports.createDevice = function(ui) {
30 | return new Device(ui)
31 | }
32 |
33 | exports.Device = Device
34 |
--------------------------------------------------------------------------------
/platform/hisense/video.js:
--------------------------------------------------------------------------------
1 | var Player = function(ui) {
2 | var player = ui._context.createElement('video')
3 | player.dom.preload = "metadata"
4 | this.player = player
5 |
6 | this.element = player
7 | this.ui = ui
8 | this.setEventListeners()
9 |
10 | ui.element.remove()
11 | ui.element = player
12 | ui.parent.element.append(ui.element)
13 |
14 | var self = this
15 | player.on('loadedmetadata', function() {
16 | log("loadedmetadata startPostion", ui.startPosition, "curr", self.element.dom.currentTime)
17 | if (ui.startPosition) {
18 | self.element.dom.currentTime = ui.startPosition
19 | ui.progress = ui.startPosition
20 | }
21 | }.bind(ui))
22 | }
23 |
24 | Player.prototype = Object.create(_globals.video.html5.backend.Player.prototype)
25 |
26 | Player.prototype.getDrmPlugin = function(url) {
27 | if (this.drmPlugin) {
28 | return this.drmPlugin
29 | } else {
30 | this.drmPlugin = document.getElementById("drmplugin")
31 | return this.drmPlugin
32 | }
33 | }
34 |
35 | Player.prototype.drmError = function(resultCode, resultMsg) {
36 | var errorMsg, errorDetail;
37 | switch(resultCode) {
38 | case 1:
39 | errorMsg = 'Unknown Error';
40 | errorDetail = 'SendDRMMessage() failed because an unspecified error occurred.';
41 | break;
42 | case 2:
43 | errorMsg = 'Cannot Process Request';
44 | errorDetail = 'SendDRMMessage() failed because the DRM agent was unable to complete the necessary computations in the time allotted.';
45 | break;
46 | case 3:
47 | errorMsg = 'Unknown MIME Type';
48 | errorDetail = 'SendDRMMessage() failed because the specified Mime Type is unknown for the specified DRM system indicated in the MIME type';
49 | break;
50 | case 4:
51 | errorMsg = 'User Consent Needed';
52 | errorDetail = 'SendDRMMessage() failed because user consent is needed for that action';
53 | break;
54 | default:
55 | errorMsg = 'Unknown Error';
56 | errorDetail = 'SendDRMMessage() failed due to Unknown Error';
57 | break;
58 | }
59 | log('DRM error', errorMsg, errorDetail);
60 | }
61 |
62 | Player.prototype.wrapCallback = function(callback) {
63 | return this.ui._context.wrapNativeCallback(callback)
64 | }
65 |
66 | Player.prototype.setSourceImpl = function(url) {
67 | log("setSourceImpl url", url)
68 | this.player.dom.src = url
69 | }
70 |
71 | Player.prototype.setSource = function(url) {
72 | log("SetSource", url)
73 | var extension = this.getFileExtension(url)
74 | this.ui.ready = false
75 |
76 | var type = ""
77 | if (extension.indexOf(".ism/manifest") >= 0 || extension.indexOf(".isml/manifest") >= 0) {
78 | type = "application/vnd.ms-sstr+xml"
79 | } else if (extension.indexOf(".mpd") >= 0) {
80 | type = "application/dash+xml"
81 | } else {
82 | type = "application/vnd.apple.mpegurl"
83 | }
84 |
85 | log("Type", type, "Extension", extension)
86 | this.player.dom.setAttribute("type", type)
87 |
88 | var self = this
89 | var ui = this.ui
90 | log("Play", url)
91 | this.setSourceImpl(url)
92 | // if (ui.autoPlay)
93 | // this.player.dom.play()
94 | }
95 |
96 | Player.prototype.setupDrm = function(type, options, callback, error) {
97 | if (type) {
98 | log("DRM type:", type)
99 | this._drm = { "type": type, "options": options }
100 | } else {
101 | this._drm = null
102 | log("DRM type:", type, "not supported, try: playready|widevine|verimatrix")
103 | }
104 |
105 | var drm = this._drm
106 | if (!drm) {
107 | error()
108 | return
109 | }
110 |
111 | log("Use DRM", JSON.stringify(drm))
112 | if (drm.type === "playready") {
113 | log("Configure playready")
114 | var laServer = drm.options.laServer ? drm.options.laServer : ""
115 | var customData = drm.options.customData ? drm.options.customData : ""
116 | var msgType = "application/vnd.ms-playready.initiator+xml"
117 | var drmSystemID = "urn:dvb:casystemid:19219"
118 | var msg = '' +
119 | '' +
120 | '' +
121 | '' + laServer + '' +
122 | '' +
123 | '' +
124 | ''+ customData +'' +
125 | '' +
126 | ''
127 |
128 | var drmPlugin = this.getDrmPlugin()
129 | if (!drmPlugin) {
130 | log("ERROR DRM plugin not found")
131 | error()
132 | return
133 | }
134 | log("Send DRM message...")
135 | var result = drmPlugin.sendDRMMessage(msgType, msg, drmSystemID)
136 | log("DRM message result: ", result)
137 | if (result != 0) {
138 | log("onDRMMessageResult failed. error:" + result)
139 | this.drmError(result)
140 | }
141 | } else {
142 | log("DRM type", drm.type, "not supported")
143 | }
144 |
145 | callback()
146 | }
147 |
148 | exports.createPlayer = function(ui) {
149 | return new Player(ui)
150 | }
151 |
152 | exports.probeUrl = function(url) {
153 | return 350
154 | }
155 |
--------------------------------------------------------------------------------
/platform/netcast/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__deviceBackend = function() { return _globals.netcast.device }
2 | _globals.core.__videoBackends.netcast = function() { return _globals.netcast.drmVideo }
3 |
4 | // log = console.log.bind(console)
5 | log = function(args) { console.log(args) }
6 |
7 | log("NetCast detected")
8 | exports.core.vendor = "LG"
9 | exports.core.device = 1
10 | exports.core.os = "netcast"
11 |
12 | var body = document.body.innerHTML
13 | document.body.innerHTML += body + ""
14 | document.body.innerHTML += ""
15 |
16 | exports.core.keyCodes = {
17 | 37: 'Left',
18 | 38: 'Up',
19 | 39: 'Right',
20 | 40: 'Down',
21 | 13: 'Select',
22 | 33: 'ChannelUp',
23 | 34: 'ChannelDown',
24 | 27: 'Back',
25 | 19: 'Pause',
26 | 48: '0',
27 | 49: '1',
28 | 50: '2',
29 | 51: '3',
30 | 52: '4',
31 | 53: '5',
32 | 54: '6',
33 | 55: '7',
34 | 56: '8',
35 | 57: '9',
36 | 461: 'Back',
37 | 403: 'Red',
38 | 404: 'Green',
39 | 405: 'Yellow',
40 | 406: 'Blue',
41 | 457: 'Menu',
42 | 412: 'Rewind',
43 | 417: 'FastForward',
44 | 457: 'Info',
45 | 413: 'Stop',
46 | 415: 'Play'
47 | }
48 |
49 | log("NetCast initialized")
50 |
51 | exports.closeApp = function() {
52 | window.NetCastBack();
53 | }
54 |
--------------------------------------------------------------------------------
/platform/netcast/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "strict": false,
3 | "templates": ["*.html", "lgconfig.xml"],
4 | "templater": "jinja2",
5 | "requires": ["video.html5"]
6 | }
7 |
--------------------------------------------------------------------------------
/platform/netcast/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | this._ui = ui
3 | this._device = document.getElementById("device")
4 | ui.supporting3d = this.getDeviceProperty("support3D")
5 | ui.macAddress = this.getDeviceProperty("net_macAddress")
6 | ui.modelName = this.getDeviceProperty("modelName")
7 | ui.deviceId = this.getDeviceProperty("serialNumber")
8 | ui.firmware = this.getDeviceProperty("version")
9 | ui.sdk = this.getDeviceProperty("SDKVersion")
10 | ui.language = this.getDeviceProperty("tvLanguage2")
11 | ui.country = this.getDeviceProperty("tvCountry2")
12 | }
13 |
14 | //Supported properties:
15 | //version
16 | //manufacturer
17 | //modelName
18 | //serialNumber
19 | //swVersion
20 | //hwVersion
21 | //SDKVersion
22 | //osdResolution
23 | //networkType
24 | //net_macAddress
25 | //drmClientInfo
26 | //net_dhcp
27 | //net_isConnected
28 | //net_hasIP
29 | //net_ipAddress
30 | //net_netmask
31 | //net_gateway
32 | //net_dns1
33 | //net_dns2
34 | //supportMouse
35 | //supportVoiceRecog
36 | //supportPentouch
37 | //support3D
38 | //support3DMode
39 | //preferredSubtitleLanguage
40 | //preferredAudioLanguage
41 | //preferredSubtitleStatus
42 | //tvLanguage2
43 | //tvCountry2
44 | //timeZone
45 | //platform
46 | //chipset
47 | Device.prototype.getDeviceProperty = function(val) { return this._device[val] }
48 |
49 | exports.createDevice = function(ui) {
50 | return new Device(ui)
51 | }
52 |
53 | exports.Device = Device
54 |
--------------------------------------------------------------------------------
/platform/netcast/dist/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/netcast/dist/icon.png
--------------------------------------------------------------------------------
/platform/netcast/dist/lgconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2
4 |
5 | 01.05.00
6 | Y
7 | Y
8 | N
9 | N
10 | 64
11 | {{ resolutionWidth | default(1280) }},{{ resolutionHeight | default(720) }}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/platform/netcast/drmVideo.js:
--------------------------------------------------------------------------------
1 | var Player = function(ui) {
2 | var player = ui._context.createElement('object')
3 | this.player = player
4 |
5 | player.dom.setAttribute("drm_type", "wm-drm")
6 | player.dom.setAttribute("type", "application/vnd.ms-sstr+xml")
7 | player.dom.setAttribute("data", "")
8 | player.dom.setAttribute("width", ui.width)
9 | player.dom.setAttribute("height", ui.height)
10 | player.style("width", ui.width)
11 | player.style("height", ui.height)
12 |
13 | this.ui = ui
14 | this.source = ''
15 |
16 | ui.element.remove()
17 | ui.element = player
18 | ui.parent.element.append(ui.element)
19 | }
20 |
21 | Player.prototype.getDrmPlugin = function(url) {
22 | if (this.drmPlugin) {
23 | return this.drmPlugin
24 | } else {
25 | this.drmPlugin = document.getElementById("drmplugin")
26 | return this.drmPlugin
27 | }
28 | }
29 |
30 | Player.prototype.drmError = function(resultCode, resultMsg) {
31 | var errorMsg, errorDetail;
32 | switch(resultCode) {
33 | case 1:
34 | errorMsg = 'Unknown Error';
35 | errorDetail = 'SendDRMMessage() failed because an unspecified error occurred.';
36 | break;
37 | case 2:
38 | errorMsg = 'Cannot Process Request';
39 | errorDetail = 'SendDRMMessage() failed because the DRM agent was unable to complete the necessary computations in the time allotted.';
40 | break;
41 | case 3:
42 | errorMsg = 'Unknown MIME Type';
43 | errorDetail = 'SendDRMMessage() failed because the specified Mime Type is unknown for the specified DRM system indicated in the MIME type';
44 | break;
45 | case 4:
46 | errorMsg = 'User Consent Needed';
47 | errorDetail = 'SendDRMMessage() failed because user consent is needed for that action';
48 | break;
49 | default:
50 | errorMsg = 'Unknown Error';
51 | errorDetail = 'SendDRMMessage() failed due to Unknown Error';
52 | break;
53 | }
54 | log('DRM error', errorMsg, errorDetail);
55 | }
56 |
57 | Player.prototype.getFileExtension = function(filePath) {
58 | if (!filePath)
59 | return ""
60 | var urlLower = filePath.toLowerCase()
61 | var querryIndex = filePath.indexOf("?")
62 | if (querryIndex >= 0)
63 | urlLower = urlLower.substring(0, querryIndex)
64 | var extIndex = urlLower.lastIndexOf(".")
65 | return urlLower.substring(extIndex, urlLower.length)
66 | }
67 |
68 | Player.prototype.wrapCallback = function(callback) {
69 | return this.ui._context.wrapNativeCallback(callback)
70 | }
71 |
72 | Player.prototype.setSource = function(url) {
73 | log("SetSource", url)
74 | var extension = this.getFileExtension(url)
75 | this.ui.ready = false
76 | this._startPosition = this.ui.startPosition
77 |
78 | var type = extension.indexOf(".ism/manifest") >= 0 || extension.indexOf(".isml/manifest") >= 0 ? "application/vnd.ms-sstr+xml" : "application/x-netcast-av"
79 | log("Type", type, "Extension", extension)
80 | this.player.dom.setAttribute("type", type)
81 |
82 | var self = this
83 | var ui = this.ui
84 | this.player.dom.onPlayStateChange = this.wrapCallback(function() {
85 | log("dom.onPlayStateChange", self.player.dom.playState)
86 | self.wrapCallback(self.stateChangedHandler(self.player.dom.playState).bind(self)).bind(self)
87 | })
88 | this.player.dom.onBuffering = this.wrapCallback(function() { log("onBuffering") })
89 |
90 | if (this._drm) {
91 | var drm = this._drm
92 | log("Use DRM", JSON.stringify(drm))
93 | if (drm.type === "wm-drm") {
94 | log("Configure playready")
95 | var laServer = drm.options.laServer ? drm.options.laServer : ""
96 | var customData = drm.options.customData ? drm.options.customData : ""
97 | var msgType = "application/vnd.ms-playready.initiator+xml";
98 | var drmSystemID = "urn:dvb:casystemid:19219";
99 | var msg = '' +
100 | '' +
101 | '' +
102 | '' + laServer + '' +
103 | '' +
104 | '' +
105 | ''+ customData +'' +
106 | '' +
107 | ''
108 |
109 | var drmPlugin = this.getDrmPlugin()
110 | if (!drmPlugin) {
111 | log("ERROR DRM plugin not found")
112 | return
113 | }
114 | drmPlugin.onDRMRightsError = this.wrapCallback(function(err) { log("onDRMRightsError", err) })
115 | drmPlugin.onDRMMessageResult = this.wrapCallback(function(msgId, resultMsg, resultCode) {
116 | log("onDRMMessageResult", resultCode)
117 | if (resultCode == 0) {
118 | log("Play with Playready DRM", url)
119 | self.player.dom.data = url
120 | if (ui.autoPlay)
121 | self.player.dom.play(1)
122 | } else {
123 | log("onDRMMessageResult failed. error:" + resultCode);
124 | self.drmError(resultCode, resultMsg);
125 | }
126 | })
127 | log("Send DRM message...")
128 | drmPlugin.sendDRMMessage(msgType, msg, drmSystemID);
129 | } else if (drm.type === "widevine") {
130 | log("Configure widevine")
131 | var options = drm.options
132 |
133 | var laServer = options.laServer || ""
134 | log("setWidevineDrmURL: '" + laServer + "'")
135 | this.player.dom.setWidevineDrmURL(laServer);
136 |
137 | var userData = options.userData || ""
138 | log("setWidevineUserData: '" + userData + "'")
139 | this.player.dom.setWidevineUserData(userData);
140 |
141 | var portal = options.portal || ""
142 | log("setWidevineUserData", portal)
143 | this.player.dom.setWidevinePortalID(portal);
144 |
145 | var deviceID = options.deviceID || ""
146 | log("setWidevineDeviceID", deviceID)
147 | this.player.dom.setWidevineDeviceID(deviceID);
148 |
149 | var clientIP = options.clientIP || ""
150 | log("setWidevineClientIP", clientIP)
151 | this.player.dom.setWidevineClientIP(clientIP);
152 |
153 | var streamID = options.streamID || ""
154 | log("setWidevineStreamID", streamID)
155 | this.player.dom.setWidevineStreamID(streamID);
156 |
157 | var drmAckServerURL = options.drmAckServerURL || ""
158 | log("setWidevineDrmAckURL", drmAckServerURL)
159 | this.player.dom.setWidevineDrmAckURL(drmAckServerURL);
160 |
161 | var drmHeartBeatPeriod = options.drmHeartBeatPeriod || ""
162 | log("setWidevineHeartbeatPeriod", drmHeartBeatPeriod)
163 | this.player.dom.setWidevineHeartbeatPeriod(drmHeartBeatPeriod);
164 | log("Widevine configured. Try to play...")
165 |
166 | this.player.dom.setWidevineDeviceType("TV")
167 | log("Type was set")
168 | this.player.dom.data = url
169 | if (ui.autoPlay)
170 | this.player.dom.play(1)
171 | } else {
172 | log("DRM type", drm.type, "not supported")
173 | }
174 | } else {
175 | log("Play", url, "Auto", ui.autoPlay)
176 | this.player.dom.data = url
177 | if (ui.autoPlay)
178 | this.player.dom.play(1)
179 | }
180 | }
181 |
182 | Player.prototype.stateChangedHandler = function(state) {
183 | log("stateChangedHandler", state)
184 | if (state === 0) {
185 | log("stopped")
186 | this.ui.ready = false
187 | this.timeUpdater = null
188 | } else if (state === 1) {
189 | log("playing")
190 | if (this._startPosition) {
191 | log("Seek to start pos", this._startPosition)
192 | this.seekTo(this._startPosition)
193 | this._startPosition = 0
194 | }
195 | this.ui.ready = true
196 | this.ui.paused = false
197 | this.ui.waiting = false
198 | this.ui.duration = this.player.dom.playTime * 1.0 / 1000
199 | if (!this.timeUpdater) {
200 | var self = this
201 | this.timeUpdater = setInterval(this.wrapCallback(function() { self.ui.progress = self.player.dom.playPosition * 1.0 / 1000; }), 500)
202 | }
203 | } else if (state === 2) {
204 | log("paused")
205 | this.ui.paused = true
206 | } else if (state === 3 || state === 4) {
207 | log("connecting || buffering")
208 | this.ui.waiting = true
209 | } else if (state === 5) {
210 | log("finished")
211 | this.ui.finished();
212 | this.ui.ready = false
213 | this.timeUpdater = null
214 | } else if (state === 6) {
215 | log("error")
216 | this.ui.error()
217 | this.ui.ready = false
218 | this.timeUpdater = null
219 | }
220 | }
221 |
222 | Player.prototype.play = function() {
223 | this.player.dom.play(1);
224 | }
225 |
226 | Player.prototype.stop = function() {
227 | this.player.dom.stop();
228 | }
229 |
230 | Player.prototype.pause = function() {
231 | this.player.dom.pause();
232 | }
233 |
234 | Player.prototype.seek = function(delta) {
235 | log("Seek delta", delta, "pro", this.ui.progress)
236 | this.seekTo(this.ui.progress + delta);
237 | }
238 |
239 | Player.prototype.seekTo = function(tp) {
240 | log("seekTo", tp)
241 | this.player.dom.seek((tp < 0 ? 0 : tp) * 1000);
242 | }
243 |
244 | Player.prototype.setVolume = function(volume) {
245 | log('NOT IMPLEMENTED: volume', volume)
246 | }
247 |
248 | Player.prototype.setMute = function(muted) {
249 | log('NOT IMPLEMENTED: mute', muted)
250 | }
251 |
252 | Player.prototype.setRect = function(l, t, r, b) {
253 | var w = r - l
254 | var h = b - t
255 | this.player.dom.setAttribute("width", w)
256 | this.player.dom.setAttribute("height", h)
257 | this.player.style("width", w)
258 | this.player.style("height", h)
259 | }
260 |
261 | Player.prototype.setVisibility = function(visible) {
262 | log('videoplayer setVisibility', visible)
263 | }
264 |
265 | Player.prototype.getVideoTracks = function() {
266 | return []
267 | }
268 |
269 | Player.prototype.getAudioTracks = function() {
270 | return []
271 | }
272 |
273 | Player.prototype.setAudioTrack = function(trackId) {
274 | log("setAudioTrack' not implemented")
275 | }
276 |
277 | Player.prototype.setVideoTrack = function(trackId) {
278 | log("setVideoTrack' not implemented")
279 | }
280 |
281 | Player.prototype.setOption = function(name, value) {
282 | }
283 |
284 | Player.prototype.setupDrm = function(type, options, callback, error) {
285 | var drmType = ""
286 | switch (type) {
287 | case "playready":
288 | drmType = "wm-drm"
289 | this.player.dom.setAttribute("drm_type", "wm-drm")
290 | break
291 | case "widevine":
292 | drmType = "widevine"
293 | this.player.dom.setAttribute("drm_type", "widevine")
294 | break
295 | case "verimatrix":
296 | // TODO: impl
297 | drmType = "verimatrix"
298 | break
299 | }
300 | if (drmType) {
301 | log("DRM type:", drmType)
302 | this._drm = { "type": drmType, "options": options }
303 | this.player.dom.setAttribute("drm_type", drmType)
304 | } else {
305 | this._drm = null
306 | log("DRM type:", drmType, "not supported, try: playready|widevine|verimatrix")
307 | }
308 | callback()
309 | }
310 |
311 | Player.prototype.setBackgroundColor = function(color) {
312 | log('NOT IMPLEMENTED: setBackgroundColor')
313 | }
314 |
315 | exports.createPlayer = function(ui) {
316 | return new Player(ui)
317 | }
318 |
319 | exports.probeUrl = function(url) {
320 | return 50
321 | }
322 |
--------------------------------------------------------------------------------
/platform/operatv/.core.js:
--------------------------------------------------------------------------------
1 | if ('VK_UNSUPPORTED' in window) {
2 | _globals.core.__deviceBackend = function() { return _globals.operatv.device }
3 |
4 | log = function(dummy) {
5 | COPY_ARGS(args, 0)
6 | console.log("[QML] " + args.join(" "))
7 | }
8 | log("operatv detected")
9 | exports.core.vendor = "operatv"
10 | exports.core.device = 1
11 | exports.core.os = "operaOS"
12 |
13 | exports.core.keyCodes = {
14 | 8: 'Back',
15 | 13: 'Select',
16 | 27: 'Back',
17 | 37: 'Left',
18 | 33: 'PageUp',
19 | 34: 'PageDown',
20 | 38: 'Up',
21 | 39: 'Right',
22 | 40: 'Down',
23 | 403: 'Red',
24 | 404: 'Green',
25 | 405: 'Yellow',
26 | 406: 'Blue',
27 | 412: 'Rewind',
28 | 413: 'Stop',
29 | 415: 'Play',
30 | 417: 'FastForward'
31 | }
32 |
33 | log("operatv initialized")
34 | }
35 |
36 | exports.closeApp = function() {
37 | log("Close operatv app. Not implemented yet")
38 | }
39 |
--------------------------------------------------------------------------------
/platform/operatv/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "strict": false,
3 | "requires": ["video.html5"]
4 | }
5 |
--------------------------------------------------------------------------------
/platform/operatv/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | ui.deviceId = "operatv_" + Math.random().toString(36).substr(2, 9)
3 | }
4 |
5 | exports.createDevice = function(ui) {
6 | return new Device(ui)
7 | }
8 |
9 | exports.Device = Device
10 |
--------------------------------------------------------------------------------
/platform/orsay/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__videoBackends.orsay = function() { return _globals.orsay.video }
2 | _globals.core.__deviceBackend = function() { return _globals.orsay.device }
3 | //samsung guts
4 | var widgetAPI
5 | var tvKey
6 | var pluginAPI
7 |
8 | log = function(dummy) {
9 | COPY_ARGS(args, 0)
10 | alert("[QML] " + args.join(" "))
11 | }
12 |
13 | if ('Common' in window) {
14 | alert("[QML] samsung smart tv")
15 | exports.core.vendor = "samsung"
16 | exports.core.device = 1
17 | exports.core.os = "orsay"
18 |
19 | log("loading")
20 | widgetAPI = new window.Common.API.Widget() // Creates Common module
21 | log("widget ok")
22 | tvKey = new window.Common.API.TVKeyValue()
23 | log("tv ok")
24 | widgetAPI.sendReadyEvent() // Sends 'ready' message to the Application Manager
25 | log("registering keys")
26 |
27 | window.onShow = function() {
28 | var NNaviPlugin = document.getElementById("pluginObjectNNavi");
29 | pluginAPI = new window.Common.API.Plugin()
30 | pluginAPI.registFullWidgetKey()
31 | pluginAPI.SetBannerState(1);
32 | NNaviPlugin.SetBannerState(2);
33 | pluginAPI.unregistKey(tvKey.KEY_VOL_UP);
34 | pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN);
35 | pluginAPI.unregistKey(tvKey.KEY_MUTE);
36 | log("plugin ok, sending ready", context)
37 | context._processActions();
38 | }
39 |
40 | exports.closeApp = function() {
41 | widgetAPI.sendExitEvent();
42 | }
43 |
44 | log("Orsay initialized")
45 | }
46 |
47 | exports.core.keyCodes = {
48 | 4: 'Left',
49 | 5: 'Right',
50 | 17: '0',
51 | 101: '1',
52 | 98: '2',
53 | 6: '3',
54 | 8: '4',
55 | 9: '5',
56 | 10: '6',
57 | 12: '7',
58 | 13: '8',
59 | 14: '9',
60 | 20: 'Green',
61 | 21: 'Yellow',
62 | 22: 'Blue',
63 | 68: 'PageUp',
64 | 65: 'PageDown',
65 | 68: 'ChannelUp',
66 | 65: 'ChannelDown',
67 | 69: 'Rewind',
68 | 70: 'Stop',
69 | 71: 'Play',
70 | 72: 'FastForward',
71 | 74: 'Pause',
72 | 88: 'Back',
73 | 108: 'Red',
74 | 262: 'Menu',
75 | 29461: 'Down',
76 | 29460: 'Up',
77 | 29443: 'Select'
78 | }
79 |
--------------------------------------------------------------------------------
/platform/orsay/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "strict": false,
3 | "templates": ["*.html", "config.xml"],
4 | "templater": "jinja2",
5 | "requires": ["html5"]
6 | }
7 |
--------------------------------------------------------------------------------
/platform/orsay/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | var deviceId
3 | if (window.webapis && window.webapis.tv) {
4 | var info = window.webapis.tv.info
5 | if (info) {
6 | deviceId = info.getDeviceID()
7 | ui.modelName = info.getModel()
8 | ui.firmware = info.getFirmware()
9 | ui.sdk = info.getVersion()
10 | ui.country = info.getCountry()
11 | ui.language = info.getLanguage()
12 | } else {
13 | log("Info object is undefined")
14 | }
15 | for (var i in info)
16 | log(i + " = " + info[i])
17 | } else {
18 | log('window.webapis is undefined, perhaps you missed ')
19 | }
20 | ui.deviceId = deviceId ? deviceId : "orsay_" + Math.random().toString(36).substr(2, 9)
21 |
22 | var network = document.getElementById("pluginObjectNetwork")
23 | if (network && network.GetMAC)
24 | ui.macAddress = network.GetMAC(0) || network.GetMAC(1)
25 | else
26 | log("Network plugin object not defined")
27 | }
28 |
29 | exports.createDevice = function(ui) {
30 | return new Device(ui)
31 | }
32 |
33 | exports.Device = Device
34 |
--------------------------------------------------------------------------------
/platform/orsay/dist/bigListIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/orsay/dist/bigListIcon.png
--------------------------------------------------------------------------------
/platform/orsay/dist/bigThumbIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/orsay/dist/bigThumbIcon.png
--------------------------------------------------------------------------------
/platform/orsay/dist/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | thumbIcon.png
8 | bigThumbIcon.png
9 | listIcon.png
10 | bigListIcon.png
11 |
12 | n
13 | 1.000
14 |
15 | y
16 | user
17 | y
18 | n
19 | n
20 | n
21 | y
22 | {{ title }}
23 |
24 | {{ resolutionWidth | default(1280) }}
25 | {{ resolutionHeight | default(720) }}
26 |
27 | {{ author.name | default('John Doe') if author is defined else 'John Doe' }}
28 | {{ author.email if author is defined else '' }}
29 | {{ author.site if author is defined else '' }}
30 | {{ author.organization | default('PureQML Team') if author is defined else 'PureQML Team' }}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/platform/orsay/dist/index.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %}
2 | {% block head %}
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {% endblock %}
13 |
--------------------------------------------------------------------------------
/platform/orsay/dist/listIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/orsay/dist/listIcon.png
--------------------------------------------------------------------------------
/platform/orsay/dist/thumbIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/orsay/dist/thumbIcon.png
--------------------------------------------------------------------------------
/platform/orsay/dist/widget.info:
--------------------------------------------------------------------------------
1 | Use Alpha Blending? = Yes
2 | Screen Resolution = 1280x720
3 |
--------------------------------------------------------------------------------
/platform/orsay/samsung-log-server:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | trap exit SIGINT
4 |
5 | while [ true ]
6 | do
7 | echo "starting server"
8 | nc -l -p 45634
9 | done
10 |
--------------------------------------------------------------------------------
/platform/orsay/video.js:
--------------------------------------------------------------------------------
1 | var Player = function(ui) {
2 | var player = ui._context.createElement('object')
3 | this.player = player
4 | this._crunchTimer = null
5 |
6 | player.dom.setAttribute("classid", "clsid:SAMSUNG-INFOLINK-SEF")
7 | this.ui = ui
8 | this.source = ''
9 |
10 | ui.element.remove()
11 | ui.element = player
12 | ui.parent.element.append(ui.element)
13 |
14 | window.Player = {}
15 | window.Player.onEvent = this.ui._context.wrapNativeCallback(function(event, arg) {
16 | if (isNaN(event))
17 | return
18 |
19 | switch (parseInt(event)) {
20 | case -1: //Fired on error?
21 | ui.error({ "message": "Unknown error", "code": -1 })
22 | break;
23 | case 1: //Connection to the stream failed
24 | ui.error({ "message": "Connection to the stream failed", "code": 1 })
25 | break;
26 | case 2: //Authentication Failed
27 | ui.error({ "message": "Authentication Failed", "code": 2 })
28 | break;
29 | case 3: //Stream not found
30 | ui.error({ "message": "Stream not found", "code": 3 })
31 | break;
32 | case 4: //Network disconnected
33 | ui.error({ "message": "Network disconnected", "code": 4 })
34 | break;
35 | case 6: //Render error
36 | var msg = ""
37 | switch (arg) {
38 | case 1: msg = 'Unsupported container'; break
39 | case 2: msg = 'Unsupported video codec'; break
40 | case 3: msg = 'Unsupported audio codec'; break
41 | case 4: msg = 'Unsupported video resolution'; break
42 | case 6: msg = 'Corrupted stream'; break
43 | default: msg = 'Unknown error'; break
44 | }
45 | log("Render error message:", msg, "code:", arg)
46 | ui.error({ "message": msg, "code": arg })
47 | break;
48 | case 7: //Fired after play was pressed --> or when ready to play?
49 | log("Ready to play")
50 | var duration = player.dom.Execute("GetDuration") / 1000
51 | log("Duration: " + duration)
52 | ui.duration = duration
53 | ui.ready = true
54 | break;
55 | case 8: //Playback came to an end (case found when rewind came to the start of the file)
56 | ui.finished()
57 | break;
58 | case 9: // SEF init ?
59 | break;
60 | case 11: //Fired after 9
61 | break;
62 | case 12: //Fired after last 13 event. Buffering complete
63 | ui.waiting = false
64 | ui.seeking = false
65 | break;
66 | case 13:// Possible that this indicates the buffering level in %
67 | ui.waiting = true
68 | break;
69 | case 14: //Fired every 0.5 seconds with current playback time in val2
70 | ui.progress = arg * 1.0 / 1000
71 | break;
72 | case 100: //DRM error
73 | ui.error({ "message": "DRM error", "code": 100 })
74 | break;
75 | default:
76 | break;
77 | }
78 | })
79 |
80 | player.dom.Open('Player', '1.000', 'Player')
81 | player.dom.OnEvent = 'Player.onEvent'
82 | }
83 |
84 | Player.prototype.startTimer = function() {
85 | if (this._crunchTimer === null)
86 | this._crunchTimer = setInterval(this.ui._context.wrapNativeCallback(this.play).bind(this), 5000)
87 | }
88 |
89 | Player.prototype.setSource = function(url) {
90 | if (url == "" || !this.visible) {
91 | return
92 | }
93 | log("Set source", url)
94 | this.player.dom.Open('Player', '1.000', 'Player')
95 | this.player.dom.OnEvent = 'Player.onEvent'
96 |
97 | this.player.dom.Execute("Stop")
98 | this.ui.ready = false
99 | this.ui.paused = false
100 | this.source = url
101 | if (this.ui.autoPlay)
102 | this.play()
103 | }
104 |
105 | Player.prototype.getFileExtension = function(filePath) {
106 | if (!filePath)
107 | return ""
108 | var urlLower = filePath.toLowerCase()
109 | var querryIndex = filePath.indexOf("?")
110 | if (querryIndex >= 0)
111 | urlLower = urlLower.substring(0, querryIndex)
112 | var extIndex = urlLower.lastIndexOf(".")
113 | return urlLower.substring(extIndex, urlLower.length)
114 | }
115 |
116 | Player.prototype.play = function() {
117 | log("video play source ", this.source)
118 | var ui = this.ui
119 | var player = this.player.dom
120 |
121 | if (!player.Execute) {
122 | log("PLAY video player not initialized yet")
123 | this.startTimer()
124 | return;
125 | }
126 |
127 | log("Player paused", ui.paused, "ready", ui.ready)
128 | if (ui.paused) {
129 | log("video play resume")
130 | player.Execute("Resume")
131 | ui.paused = false
132 | return
133 | } else if (ui.ready) {
134 | log("Stream is playing already")
135 | return
136 | }
137 |
138 | var component = ""
139 | var extension = this.getFileExtension(this.source)
140 | if (extension === ".m3u8" || extension === ".m3u")
141 | component = "|COMPONENT=HLS"
142 |
143 | if (this._drm)
144 | component += '|COMPONENT=WMDRM';
145 |
146 | log("Extension", extension, "Component", component)
147 | player.Execute("InitPlayer", this.source + component)
148 |
149 | if (this._drm) {
150 | var options = this._drm.options
151 | log("DRM", JSON.stringify(options))
152 | if (options.customData)
153 | player.Execute('SetPlayerProperty', '3', options.customData, options.customData.length);
154 | if (options.laServer)
155 | player.Execute('SetPlayerProperty', '4', options.laServer, options.laServer.length);
156 | }
157 |
158 | ui.waiting = true
159 | log("calling StartPlayback")
160 | log("StartPlayback returns", player.Execute("StartPlayback", ui.startPosition))
161 | }
162 |
163 | Player.prototype.stop = function() {
164 | log("video stop and close", this.player.dom.Execute)
165 | if (this.player.dom.Execute) {
166 | this.player.dom.Execute("Stop")
167 | this.player.dom.Execute("Close")
168 | }
169 | this.ui.ready = false
170 | }
171 |
172 | Player.prototype.pause = function() {
173 | if (this.ui.ready) {
174 | log("video pause")
175 | this.player.dom.Execute("Pause")
176 | this.ui.paused = true
177 | }
178 | }
179 |
180 | Player.prototype.seek = function(delta) {
181 | log('seekTo', delta)
182 | this.ui.seeking = true
183 | this.player.dom.Execute("JumpForward", delta)
184 | }
185 |
186 | Player.prototype.seekTo = function(tp) {
187 | this.seek(tp - this.ui.progress)
188 | }
189 |
190 | Player.prototype.setVolume = function(volume) {
191 | log('NOT IMPLEMENTED: setVolume', volume)
192 | }
193 |
194 | Player.prototype.setMute = function(muted) {
195 | log('NOT IMPLEMENTED: mute', muted)
196 | }
197 |
198 | Player.prototype.setRect = function(l, t, r, b) {
199 | var w = r - l, h = b - t
200 | this.player.dom.Execute("SetDisplayArea", l, t, w, h)
201 | }
202 |
203 | Player.prototype.setVisibility = function(visible) {
204 | log('videoplayer setVisibility', visible)
205 | this.visible = visible
206 | if (visible)
207 | this.setSource(this.ui.source)
208 | else
209 | this.stop()
210 | }
211 |
212 | Player.prototype.getVideoTracks = function() {
213 | return []
214 | }
215 |
216 | Player.prototype.getAudioTracks = function() {
217 | return []
218 | }
219 |
220 | Player.prototype.setOption = function(name, value) {
221 | }
222 |
223 | Player.prototype.setAudioTrack = function(trackId) {
224 | log("setAudioTrack' not implemented")
225 | }
226 |
227 | Player.prototype.setVideoTrack = function(trackId) {
228 | log("setVideoTrack' not implemented")
229 | }
230 |
231 | Player.prototype.setupDrm = function(type, options, callback, error) {
232 | if (type === "playready") {
233 | log("DRM type:", type)
234 | this._drm = { "type": type, "options": options }
235 | } else {
236 | this._drm = null
237 | log("DRM type:", drmType, "not supported, try: playready")
238 | }
239 | callback()
240 | }
241 |
242 | Player.prototype.setBackgroundColor = function(color) {
243 | log('NOT IMPLEMENTED: setBackgroundColor')
244 | }
245 |
246 | exports.createPlayer = function(ui) {
247 | return new Player(ui)
248 | }
249 |
250 | exports.probeUrl = function(url) {
251 | return 75
252 | }
253 |
--------------------------------------------------------------------------------
/platform/tizen/.core.js:
--------------------------------------------------------------------------------
1 | _globals.core.__videoBackends.tizen = function() { return _globals.tizen.video }
2 | _globals.core.__deviceBackend = function() { return _globals.tizen.device }
3 |
4 | log = console.log.bind(console)
5 |
6 | if ('tizen' in window) {
7 | log("[QML] Tizen")
8 | exports.core.vendor = "samsung"
9 | exports.core.device = 1
10 | exports.core.os = "tizen"
11 |
12 | var inputDevice = window.tizen.tvinputdevice
13 | if (inputDevice) {
14 | inputDevice.registerKey("0")
15 | inputDevice.registerKey("1")
16 | inputDevice.registerKey("2")
17 | inputDevice.registerKey("3")
18 | inputDevice.registerKey("4")
19 | inputDevice.registerKey("5")
20 | inputDevice.registerKey("6")
21 | inputDevice.registerKey("7")
22 | inputDevice.registerKey("8")
23 | inputDevice.registerKey("9")
24 | inputDevice.registerKey("ColorF0Red")
25 | inputDevice.registerKey("ColorF1Green")
26 | inputDevice.registerKey("ColorF2Yellow")
27 | inputDevice.registerKey("ColorF3Blue")
28 | inputDevice.registerKey("ChannelUp")
29 | inputDevice.registerKey("ChannelDown")
30 | inputDevice.registerKey("MediaFastForward")
31 | inputDevice.registerKey("MediaPlayPause")
32 | inputDevice.registerKey("MediaRewind")
33 | inputDevice.registerKey("MediaPlay")
34 | inputDevice.registerKey("MediaStop")
35 | inputDevice.registerKey("MediaPause")
36 | } else {
37 | log('"inputDevice" is undefined dont forget to add privilege: into the "config.xml"')
38 | }
39 |
40 | exports.closeApp = function() {
41 | window.tizen.application.getCurrentApplication().exit();
42 | }
43 |
44 | log("tizen initialized")
45 | }
46 |
47 | exports.core.keyCodes = {
48 | 48: '0',
49 | 49: '1',
50 | 50: '2',
51 | 51: '3',
52 | 52: '4',
53 | 53: '5',
54 | 54: '6',
55 | 55: '7',
56 | 56: '8',
57 | 57: '9',
58 | 37: 'Left',
59 | 38: 'Up',
60 | 39: 'Right',
61 | 40: 'Down',
62 | 13: 'Select',
63 | 19: 'Pause',
64 | 403: 'Red',
65 | 404: 'Green',
66 | 405: 'Yellow',
67 | 406: 'Blue',
68 | 427: 'ChannelUp',
69 | 428: 'ChannelDown',
70 | 457: 'Menu',
71 | 415: 'Play',
72 | 413: 'Stop',
73 | 412: 'Rewind',
74 | 417: 'FastForward',
75 | 10252: 'Pause',
76 | 10009: 'Back'
77 | }
78 |
--------------------------------------------------------------------------------
/platform/tizen/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "strict": false,
3 | "templates": ["*.html", "config.xml"],
4 | "templater": "jinja2",
5 | "requires": ["video.html5"]
6 | }
7 |
--------------------------------------------------------------------------------
/platform/tizen/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | if (!window.tizen) {
3 | log("'window.tizen' not defined")
4 | return
5 | }
6 |
7 | var webapis = window.webapis
8 | this._ui = ui
9 | var tizenDeviceId = webapis && webapis.productinfo && webapis.productinfo.getDuid ? webapis.productinfo.getDuid() : ""
10 |
11 | if (!tizenDeviceId) {
12 | tizenDeviceId = window.tizen.systeminfo.getCapability("http://tizen.org/system/tizenid")
13 | }
14 |
15 | log("deviceId", tizenDeviceId)
16 | ui.deviceId = tizenDeviceId
17 |
18 | window.tizen.systeminfo.getPropertyValue("BUILD", this.fillDeviceInfo.bind(this), function(error) { log("Failed to get devceinfo", error) });
19 |
20 | if (webapis && webapis.avinfo)
21 | ui.supportingHdr = webapis.avinfo.isHdrTvSupport()
22 | else
23 | log("ERROR: webapis is undefined")
24 |
25 | var userAgent = window.navigator ? window.navigator.userAgent : ""
26 | if (userAgent) {
27 | userAgent = userAgent.toLowerCase()
28 | var begin = userAgent.indexOf("tizen")
29 | var endSemicolon = userAgent.indexOf(";", begin)
30 | var endBrace = userAgent.indexOf(")", begin)
31 | var end = endSemicolon > -1 && endSemicolon < endBrace ? endSemicolon : (endBrace < 0 ? userAgent.length - 1 : endBrace)
32 | ui.sdk = userAgent.substring(begin + 6, end)
33 | }
34 |
35 | if (webapis && webapis.productinfo)
36 | ui.supportingUhd = webapis.productinfo.isUdPanelSupported()
37 | }
38 |
39 | Device.prototype.getDeviceProperty = function(device) {
40 | if (!device) {
41 | log("Device info is null")
42 | return
43 | }
44 | this._ui.modelName = device.model
45 | this._ui.firmware = device.buildVersion
46 | }
47 |
48 | Device.prototype.fillDeviceInfo = function(device) {
49 | if (!device) {
50 | log("Device info is null")
51 | return
52 | }
53 | var ui = this._ui
54 | ui.modelName = device.model
55 | ui.firmware = device.buildVersion
56 | }
57 |
58 | exports.createDevice = function(ui) {
59 | return new Device(ui)
60 | }
61 |
62 | exports.Device = Device
63 |
--------------------------------------------------------------------------------
/platform/tizen/dist/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | {% block feature %}{% endblock %}
9 |
10 |
11 | {{ title }}
12 |
13 |
14 |
15 |
16 |
17 | {% block privilege %}{% endblock %}
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/platform/tizen/dist/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/tizen/dist/icon.png
--------------------------------------------------------------------------------
/platform/tizen/dist/index.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %}
2 | {% block head %}
3 |
4 | {% endblock %}
5 |
--------------------------------------------------------------------------------
/platform/tizen/video.js:
--------------------------------------------------------------------------------
1 | var Player = function(ui) {
2 | var player = ui._context.createElement('object')
3 | player.dom.setAttribute("id", "av-player")
4 | player.dom.setAttribute("type", "application/avplayer")
5 | if (!window.webapis) {
6 | log('"webapis" is undefined, maybe is missed.')
7 | return
8 | }
9 | this._webapis = window.webapis
10 | log("WEBAPIS", this._webapis)
11 |
12 | this.ui = ui
13 |
14 | ui.element.remove()
15 | ui.element = player
16 | ui.parent.element.append(ui.element)
17 |
18 | var self = this
19 | ui.setNotSuspendFlag = function(value) { self._notSuspend = value }.bind(this)
20 | var context = ui._context
21 | this._listener = {
22 | onbufferingstart : this.wrapCallback(function() {
23 | log("onbufferingstart")
24 | self.ui.waiting = true
25 | self.ui.seeking = true
26 | }),
27 | onbufferingprogress : this.wrapCallback(function(percent) {
28 | log("onbufferingprogress")
29 | context._processActions()
30 | }),
31 | onbufferingcomplete : this.wrapCallback(function() {
32 | log("onbufferingcomplete")
33 | self.ui.seeking = false
34 | self.ui.waiting = false
35 | }),
36 | oncurrentplaytime : this.wrapCallback(function(currentTime) {
37 | if (currentTime)
38 | self.ui.waiting = false
39 | self.ui.ready = true
40 | self.updateCurrentTime(currentTime);
41 | }),
42 | onevent : this.wrapCallback(function(eventType, eventData) {
43 | log("event type: " + eventType + ", data: " + eventData);
44 | }),
45 | onerror : this.wrapCallback(function(eventType) {
46 | log("error type: " + eventType);
47 | self.ui.ready = false
48 | self.ui.error({ "type": eventType, "message": eventType })
49 | }),
50 | onsubtitlechange : this.wrapCallback(function(duration, text, data3, data4) {
51 | log("Subtitle Changed.");
52 | self.ui.text(text, duration, data4)
53 | }),
54 | ondrmevent : this.wrapCallback(function(drmEvent, drmData) {
55 | log("DRM callback: " + drmEvent + ", data: " + JSON.stringify(drmData));
56 | var avplay = self.getAVPlay()
57 | avplay.setDrm("PLAYREADY", "InstallLicense", JSON.stringify(self._drmParam));
58 | }),
59 | onstreamcompleted : this.wrapCallback(function(e) {
60 | if (ui.progress < ui.duration - 1) {
61 | log("Unexpected ending error occured")
62 | self.ui.error({
63 | "type": "PLAYER_ERROR_UNEXPECTED_ENDING",
64 | "message": "Unexpected ending. Progress is " + ui.progress + " but duration is " + ui.duration
65 | })
66 | return
67 | }
68 |
69 | if (self.ui.loop) {
70 | log("Video is looped play it again")
71 | var avplay = self.getAVPlay()
72 | avplay.seekTo(0)
73 | } else {
74 | log("Stream Completed");
75 | self.ui.ready = false
76 | self.ui.finished()
77 | }
78 | })
79 | };
80 |
81 | var tizen = window.tizen
82 | if (tizen && tizen.systeminfo)
83 | tizen.systeminfo.getPropertyValue("BUILD", this.fillDeviceInfo.bind(this));
84 | }
85 |
86 | Player.prototype.fillDeviceInfo = function(device) {
87 | log("Fill deviceinfo in player", device)
88 | if (device && device.model) {
89 | var modelName = device.model.toLowerCase()
90 | var webapis = window.webapis
91 | log("Device modelName", modelName)
92 | if (webapis && webapis.productinfo) {
93 | this._uhdSupported = webapis.productinfo.isUdPanelSupported()
94 | } else {
95 | log("productinfo is undefined try to retrive UHD support flag from modelname")
96 | var checkUhdSubName = function(sub) { return modelName.indexOf(sub) >= 0 }
97 | this._uhdSupported = checkUhdSubName("mu") || checkUhdSubName("ks") || checkUhdSubName("ku") || checkUhdSubName("hu")
98 | }
99 | } else {
100 | this._uhdSupported = false
101 | }
102 | }
103 |
104 | Player.prototype.wrapCallback = function(callback) {
105 | return this.ui._context.wrapNativeCallback(callback)
106 | }
107 |
108 | Player.prototype.getAVPlay = function() {
109 | var webapis = this._webapis
110 | return webapis && webapis.avplay ? webapis.avplay : null
111 | }
112 |
113 | Player.prototype.setSource = function(value) {
114 | log("src", value)
115 | this.ui.ready = false
116 | log("drmRequired", this._drmRequired)
117 | if (this._drmRequired && this._drm)
118 | this._drmRequired = false
119 | else
120 | this._drm = null
121 |
122 | if (this._suspendState) {
123 | this._suspendState.url = value
124 | this._suspendState.progress = this.ui.startPosition
125 | }
126 | this.playImpl()
127 | }
128 |
129 | Player.prototype.playImpl = function() {
130 | var avplay = this.getAVPlay()
131 | if (!avplay) {
132 | log("AVPlay was not initialized")
133 | return
134 | }
135 | var ui = this.ui
136 | if (!ui.source)
137 | return
138 | var state = avplay.getState()
139 | log("playImpl", state, "src", ui.source)
140 |
141 | if (state != 'NONE')
142 | this.closeVideo()
143 |
144 | log("playImpl", ui.source, "state", state)
145 | ui.duration = 0
146 | log("playImpl open")
147 | avplay.open(ui.source);
148 | log("playImpl setListener")
149 | avplay.setListener(this._listener);
150 | log("Init player, src:", ui.source, "width:", ui.width, "height:", ui.height)
151 | log("DRM:", this._drm)
152 | if (this._drm) {
153 | log('Apply DRM:', this._drm);
154 | var drm = this._drm
155 | if (drm.widevine) {
156 | var deviceId = window.webapis.drminfo.getEsn('WIDEVINE');
157 | var licenseServer = drm.widevine.laServer;
158 | this._drmParam = "DEVICE_ID=" + deviceId + "|DEVICE_TYPE_ID=60|STREAM_ID=|IP_ADDR=|DRM_URL=" + licenseServer + "|PORTAL=OEM|I_SEEK=|CUR_TIME=|USER_DATA=";
159 | avplay.setStreamingProperty("WIDEVINE", this._drmParam);
160 | avplay.setDrm("WIDEVINE", "SetProperties", JSON.stringify(this._drmParam));
161 | } else if (drm.playready) {
162 | this._drmParam = { LicenseServer: drm.playready.laServer };
163 | avplay.setDrm("PLAYREADY", "SetProperties", JSON.stringify(this._drmParam));
164 | }
165 | }
166 | avplay.setDisplayRect(ui.x, ui.y, ui.width, ui.height);
167 | log("Set UHD flag", this._uhdSupported, "allowUhdPlaying", ui.allowUhdPlaying, "startPos", ui.startPosition)
168 | avplay.setStreamingProperty("SET_MODE_4K", ui.allowUhdPlaying && this._uhdSupported ? "TRUE" : "FALSE");
169 | avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_FULL_SCREEN");
170 |
171 | if (ui.startPosition)
172 | avplay.seekTo(ui.startPosition * 1000, function() { log("seeked on start") }, function(err) { log("failed to seek on start",err) });
173 |
174 | log("playImpl prepare")
175 | var self = this
176 | avplay.prepareAsync(function() {
177 | log("Current state: " + avplay.getState());
178 | log("prepare complete source", ui.source);
179 | self.updateDuration()
180 | var ready = avplay.getState() === "READY"
181 | if (ui.autoPlay)
182 | self.play()
183 | log("prepare complete", ui.ready, "autoplay", ui.autoPlay);
184 | ui.ready = ready
185 | })
186 | }
187 |
188 | Player.prototype.play = function() {
189 | var avplay = this.getAVPlay()
190 | if (!avplay) {
191 | log("AVPlay was not initialized")
192 | return
193 | }
194 | log('Play Video', this.ui.source);
195 | try {
196 | avplay.play();
197 | this.ui.paused = avplay.getState() == "PAUSED"
198 | log("Current state: " + avplay.getState());
199 | } catch (e) {
200 | log(e);
201 | }
202 | }
203 |
204 | Player.prototype.setupDrm = function(type, options, callback, error) {
205 | if (type === "widevine") {
206 | this._drm = {}
207 | this._drm["widevine"] = options
208 | } else if (type === "playready") {
209 | this._drm = {}
210 | this._drm["playready"] = options
211 | } else {
212 | error ? error(new Error("Unkbown or not supported DRM type " + type)) : log("Unkbown or not supported DRM type " + type)
213 | }
214 |
215 | var avplay = this.getAVPlay()
216 | var drm = this._drm
217 | log('Apply DRM:', this._drm);
218 | if (callback)
219 | callback()
220 | }
221 |
222 | Player.prototype.getVideoTracks = function() {
223 | var video = [ { "name": "auto", "id": "auto" } ]
224 | var avplay = this.getAVPlay()
225 | var tracks = avplay.getTotalTrackInfo()
226 |
227 | for (var i = 0; i < tracks.length; ++i) {
228 | var track = tracks[i]
229 | if (track.type !== "VIDEO")
230 | continue
231 |
232 | var info = JSON.parse(track.extra_info)
233 | video.push({
234 | id: parseInt(track.index),
235 | width: parseInt(info.Width),
236 | height: parseInt(info.Height)
237 | })
238 | }
239 | return video
240 | }
241 |
242 | Player.prototype.getSubtitles = function() {
243 | var subtitles = []
244 | var avplay = this.getAVPlay()
245 | var tracks = avplay.getTotalTrackInfo()
246 |
247 | for (var i = 0; i < tracks.length; ++i) {
248 | var track = tracks[i]
249 | if (track.type !== "TEXT")
250 | continue
251 |
252 | var info = JSON.parse(track.extra_info)
253 |
254 | subtitles.push({
255 | id: parseInt(track.index),
256 | language: info.track_lang
257 | })
258 | }
259 | log("Got subtitles", subtitles)
260 | return subtitles
261 | }
262 |
263 | Player.prototype.getAudioTracks = function() {
264 | var audio = []
265 | var avplay = this.getAVPlay()
266 | var tracks = avplay.getTotalTrackInfo()
267 |
268 | for (var i = 0; i < tracks.length; ++i) {
269 | var track = tracks[i]
270 | if (track.type !== "AUDIO")
271 | continue
272 |
273 | var info = JSON.parse(track.extra_info)
274 | audio.push({
275 | id: parseInt(track.index),
276 | language: info.language,
277 | bitRate: parseInt(info.bit_rate),
278 | codec: info.fourCC
279 | })
280 | }
281 | return audio
282 | }
283 |
284 | Player.prototype.setSubtitles = function(trackId) {
285 | var avplay = this.getAVPlay()
286 | var tracks = avplay.getTotalTrackInfo()
287 |
288 | var found = tracks.filter(function(element) {
289 | return parseInt(element.index) === trackId
290 | })
291 |
292 | log("Try to set subtitles", found)
293 | if (found && found.length)
294 | avplay.setSelectTrack('TEXT', parseInt(found[0].index));
295 | }
296 |
297 | Player.prototype.setAudioTrack = function(trackId) {
298 | var avplay = this.getAVPlay()
299 | var tracks = avplay.getTotalTrackInfo()
300 |
301 | var found = tracks.filter(function(element) {
302 | return parseInt(element.index) === trackId
303 | })
304 |
305 | log("Try to set audio track", found)
306 | if (found && found.length) {
307 | log("Seek after audio state", avplay.getState())
308 | avplay.setSelectTrack('AUDIO', parseInt(found[0].index));
309 | this.seek(1)
310 | }
311 | }
312 |
313 | Player.prototype.setVideoTrack = function(trackId) {
314 | log("setVideoTrack for", trackId)
315 | var avplay = this.getAVPlay()
316 | var tracks = avplay.getTotalTrackInfo()
317 | log("Total tracks", tracks)
318 |
319 | if (trackId === "auto") {
320 | var bitRateString = 'BITRATES=5000~50000|STARTBITRATE=HIGHEST|SKIPBITRATE=LOWEST'
321 | try {
322 | avplay.setStreamingProperty('ADAPTIVE_INFO', bitRateString)
323 | } catch(e) {
324 | log("Failed to cahgne bitrate", e)
325 | }
326 |
327 | } else {
328 | var found = tracks.filter(function(element) {
329 | return parseInt(element.index) === trackId
330 | })
331 |
332 | log("Found", found)
333 | if (!found || !found.length)
334 | return
335 | var info = JSON.parse(found[0].extra_info)
336 | var bitRateString = 'BITRATES=5000~' + info.Bit_rate + "|STARTBITRATE=HIGHEST|SKIPBITRATE=LOWEST";
337 | log("Found info", bitRateString, "INFO", info)
338 | try {
339 | avplay.setStreamingProperty('ADAPTIVE_INFO', bitRateString)
340 | } catch(e) {
341 | log("Failed to cahgne bitrate", e)
342 | }
343 | }
344 | var prevProgress = this.ui.progress
345 | avplay.close();
346 | this.playImpl();
347 | if (prevProgress > 12)
348 | this.seekTo(prevProgress)
349 | }
350 |
351 | Player.prototype.setVisibility = function(visible) {
352 | var avplay = this.getAVPlay()
353 | if (!avplay) {
354 | log("AVPlay was not initialized")
355 | return
356 | }
357 |
358 | log("setVisibility", visible, "state", avplay.getState(), "notsuspend", this._notSuspend)
359 | if (this._notSuspend)
360 | return
361 |
362 | if (visible) {
363 | log("Check suspend state", this._suspendState)
364 | if (this._suspendState) {
365 | var state = this._suspendState
366 | try {
367 | avplay.restore(state.url, state.progress * 1000)
368 | } catch (e) {
369 | log("Failed to restore")
370 | }
371 | }
372 | this._suspendState = null
373 | } else {
374 | try {
375 | this._suspendState = {
376 | progress: this.ui.progress,
377 | url: this.ui.source
378 | }
379 | avplay.suspend()
380 | } catch (e) {
381 | log("Failed to suspend avplay", e)
382 | }
383 | }
384 | }
385 |
386 | Player.prototype.pause = function() {
387 | var avplay = this.getAVPlay()
388 | if (!avplay) {
389 | log("AVPlay was not initialized")
390 | return
391 | }
392 |
393 | log('Pause Video', avplay);
394 | try {
395 | avplay.pause();
396 | this.ui.paused = avplay.getState() == "PAUSED"
397 | log("Current state: " + avplay.getState());
398 | } catch (e) {
399 | log(e);
400 | }
401 | }
402 |
403 | //missing API in VideoPlayer
404 | Player.prototype.stop = function() {
405 | var avplay = this.getAVPlay()
406 | if (!avplay) {
407 | log("AVPlay was not initialized")
408 | return
409 | }
410 |
411 | log("Current state: " + avplay.getState());
412 | log('Stop Video');
413 | try {
414 | avplay.stop();
415 | log("Current state: " + avplay.getState());
416 | } catch (e) {
417 | log("Current state: " + avplay.getState());
418 | log(e);
419 | }
420 | }
421 |
422 | Player.prototype.seek = function(delta) {
423 | this.seekTo(this.ui.progress + delta)
424 | }
425 |
426 | Player.prototype.seekTo = function(tp) {
427 | var avplay = this.getAVPlay()
428 | if (!avplay) {
429 | log("AVPlay was not initialized")
430 | return
431 | }
432 | log("Seek to", tp, this.ui.progress)
433 | this.ui.seeking = true
434 | this.ui.progress = tp
435 | avplay.seekTo(tp * 1000)
436 | }
437 |
438 | Player.prototype.setVolume = function(volume) {
439 | // TODO: its set to max the system volume
440 | // window.tizen.tvaudiocontrol.setVolume(volume)
441 | }
442 |
443 | Player.prototype.setMute = function(muted) {
444 | window.tizen.tvaudiocontrol.setMute(muted)
445 | this.ui.muted = muted
446 | }
447 |
448 | Player.prototype.setRect = function(l, t, r, b) {
449 | var avplay = this.getAVPlay()
450 | if (!avplay) {
451 | log("AVPlay was not initialized")
452 | return
453 | }
454 | avplay.setDisplayRect(l, t, r - l, b - t)
455 | }
456 |
457 | Player.prototype.setBackgroundColor = function(color) {
458 | log("Not implemented")
459 | }
460 |
461 | Player.prototype.setLoop = function(loop) {
462 | log("Not implemented")
463 | }
464 |
465 | Player.prototype.closeVideo = function() {
466 | var avplay = this.getAVPlay()
467 | if (!avplay) {
468 | log("AVPlay was not initialized")
469 | return
470 | }
471 | log("Current state: " + avplay.getState());
472 | log('Close Video');
473 | try {
474 | avplay.close();
475 | log("Current state: " + avplay.getState());
476 | } catch (e) {
477 | log("Current state: " + avplay.getState());
478 | log(e);
479 | }
480 | }
481 |
482 | Player.prototype.updateDuration = function() {
483 | var avplay = this.getAVPlay()
484 | if (!avplay) {
485 | log("AVPlay was not initialized")
486 | return
487 | }
488 | this.ui.duration = avplay.getDuration() / 1000
489 | log("Duration", this.ui.duration)
490 | }
491 |
492 | Player.prototype.setOption = function(name, value) {
493 | }
494 |
495 | Player.prototype.updateCurrentTime = function() {
496 | var avplay = this.getAVPlay()
497 | if (!avplay) {
498 | log("AVPlay was not initialized")
499 | return
500 | }
501 | this.ui.progress = avplay.getCurrentTime() / 1000
502 | }
503 |
504 | exports.createPlayer = function(ui) {
505 | return new Player(ui)
506 | }
507 |
508 | exports.probeUrl = function(url) {
509 | return 75
510 | }
511 |
--------------------------------------------------------------------------------
/platform/webos/.core.js:
--------------------------------------------------------------------------------
1 | if ('webOS' in window || 'webos' in window) {
2 | _globals.core.__videoBackends.webos = function() { return _globals.webos.video }
3 | _globals.core.__deviceBackend = function() { return _globals.webos.device }
4 |
5 | log = console.log.bind(console)
6 |
7 | log("WebOS detected")
8 | exports.core.vendor = "LG"
9 | exports.core.device = 1
10 | exports.core.os = "webOS"
11 |
12 | exports.core.keyCodes = {
13 | 37: 'Left',
14 | 38: 'Up',
15 | 39: 'Right',
16 | 40: 'Down',
17 | 13: 'Select',
18 | 33: 'ChannelUp',
19 | 34: 'ChannelDown',
20 | 27: 'Back',
21 | 19: 'Pause',
22 | 48: '0',
23 | 49: '1',
24 | 50: '2',
25 | 51: '3',
26 | 52: '4',
27 | 53: '5',
28 | 54: '6',
29 | 55: '7',
30 | 56: '8',
31 | 57: '9',
32 | 461: 'Back',
33 | 403: 'Red',
34 | 404: 'Green',
35 | 405: 'Yellow',
36 | 406: 'Blue',
37 | 457: 'Menu',
38 | 412: 'Rewind',
39 | 417: 'FastForward',
40 | 457: 'Info',
41 | 413: 'Stop',
42 | 415: 'Play'
43 | }
44 |
45 | log("webos initialized")
46 |
47 | exports.closeApp = function() {
48 | if (window.close)
49 | window.close()
50 | else
51 | window.webOS.platformBack();
52 | }
53 |
54 | exports.platformBack = function() {
55 | window.webOS.platformBack();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/platform/webos/.manifest:
--------------------------------------------------------------------------------
1 | {
2 | "requires": ["video.html5"],
3 | "templates": ["*.html", "appinfo.json"],
4 | "templater": "jinja2",
5 | "strict": false
6 | }
7 |
--------------------------------------------------------------------------------
/platform/webos/LunaServiceApi.qml:
--------------------------------------------------------------------------------
1 | Object {
2 |
3 | requestImpl(serviceUri, requestObject): {
4 | if (!window.webOS) {
5 | log("webOS not found! Maybe you forget to include webOS.js.")
6 | return
7 | }
8 | window.webOS.service.request(serviceUri, requestObject)
9 | }
10 |
11 | fillRequest(method, args, success, error, complete): {
12 | var res = {
13 | method: method,
14 | parameters: args,
15 | onSuccess: function(response) { success(response) }
16 | }
17 |
18 | if (error)
19 | res.onFailure = function(response) { error(response) }
20 |
21 | if (complete)
22 | res.onComplete = function(response) { complete(response) }
23 |
24 | if (args.subscribe)
25 | res['subscribe'] = args.subscribe
26 |
27 | if (args.resubscribeStatus)
28 | res['resubscribeStatus'] = args.resubscribeStatus
29 |
30 | return res;
31 | }
32 |
33 | getSystemInfo(callback, error): {
34 | var request = this.fillRequest("getSystemInfo", { "keys": ["modelName", "firmwareVersion", "UHD", "sdkVersion", "_3d"] }, callback, error)
35 | this.requestImpl("luna://com.webos.service.tv.systemproperty", request)
36 | }
37 |
38 | getDeviceId(callback, error): {
39 | var request = this.fillRequest("deviceid/getIDs", { "idType": ["LGUDID"] }, callback, error)
40 | this.requestImpl("luna://com.webos.service.sm", request)
41 | }
42 |
43 | keyManager(method, args, success, error, complete): {
44 | var request = this.fillRequest(method, args, success, error, complete)
45 | this.requestImpl("luna://com.palm.keymanager", request)
46 | }
47 |
48 | getInternetStatusRequest(callback): {
49 | var request = this.fillRequest("getStatus", {"subscribe":true}, callback)
50 | this.requestImpl("luna://com.palm.connectionmanager", request)
51 | }
52 |
53 | launchApp(id, params, callback, error): {
54 | var request = this.fillRequest("launch", { 'id': id, 'params': params }, callback, error)
55 | this.requestImpl("luna://com.webos.applicationManager", request)
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/platform/webos/device.js:
--------------------------------------------------------------------------------
1 | var Device = function(ui) {
2 | this._ui = ui
3 | var self = this
4 | this.lunaGetSystemInfo(function(res) { log("Device info", res); self.fillSystemInfo(res) }, function(res) { log("Failed to get device info", res) })
5 | this.getDeviceId(function(deviceId) { log("Get ID", deviceId); ui.deviceId = deviceId }.bind(this))
6 | }
7 |
8 | Device.prototype.lunaRequestImpl = function(serviceUri, requestObject) {
9 | if (!window.webOS) {
10 | log("webOS not found! Maybe you forget to include webOS.js.")
11 | return
12 | }
13 | window.webOS.service.request(serviceUri, requestObject)
14 | }
15 |
16 | Device.prototype.lunaFillRequest = function(method, args, success, error, complete) {
17 | var res = {
18 | method: method,
19 | parameters: args,
20 | onSuccess: function(response) { success(response) }
21 | }
22 |
23 | if (error)
24 | res.onFailure = function(response) { error(response) }
25 |
26 | if (complete)
27 | res.onComplete = function(response) { complete(response) }
28 |
29 | if (args.subscribe)
30 | res['subscribe'] = args.subscribe
31 |
32 | if (args.resubscribeStatus)
33 | res['resubscribeStatus'] = args.resubscribeStatus
34 |
35 | return res;
36 | }
37 |
38 | Device.prototype.lunaGetSystemInfo = function(callback, error) {
39 | var request = this.lunaFillRequest("getSystemInfo", { "keys": ["modelName", "firmwareVersion", "UHD", "sdkVersion", "_3d"] }, callback, error)
40 | this.lunaRequestImpl("luna://com.webos.service.tv.systemproperty", request)
41 | }
42 |
43 | Device.prototype.generateId = function(callback) {
44 | log("Generate id...")
45 | this.lunaKeyManager("generate", {"keyname": "deviceid", "type": "AES", "size": 16, "nohide": true},
46 | function(res) { log("Id was generated") },
47 | function(res) { log("Failed to generate id:", res) }
48 | )
49 |
50 | this.lunaKeyManager("fetchKey", {"keyname": "deviceid"},
51 | function(res) { callback(res.keydata) },
52 | function(res) { log("Failed to fetch id:", res) }
53 | )
54 | }
55 |
56 | Device.prototype.getDeviceId = function(callback) {
57 | var self = this
58 | this.lunaGetDeviceId(
59 | function(res) {
60 | if (res.returnValue && res.idList && res.idList.length) {
61 | log("Succss, deviceId:", res.idList[0].idValue)
62 | callback(res.idList[0].idValue)
63 | } else {
64 | log("Bad response, device Id will be generated", res)
65 | self.generateId(callback)
66 | }
67 | },
68 | function(res) { log("Failed to get device id directly"); self.generateId(callback) }
69 | )
70 | }
71 |
72 | Device.prototype.lunaRequestImpl = function(serviceUri, requestObject) {
73 | if (!window.webOS) {
74 | log("webOS not found! Maybe you forget to include webOS.js.")
75 | return
76 | }
77 | window.webOS.service.request(serviceUri, requestObject)
78 | }
79 |
80 | Device.prototype.lunaGetDeviceId = function(callback, error) {
81 | var request = this.lunaFillRequest("deviceid/getIDs", { "idType": ["LGUDID"] }, callback, error)
82 | this.lunaRequestImpl("luna://com.webos.service.sm", request)
83 | }
84 |
85 | Device.prototype.lunaKeyManager = function(method, args, success, error, complete) {
86 | var request = this.lunaFillRequest(method, args, success, error, complete)
87 | this.lunaRequestImpl("luna://com.palm.keymanager", request)
88 | }
89 |
90 | Device.prototype.fillSystemInfo = function(info) {
91 | this._ui.supportingUhd = info.UHD
92 | this._ui.supporting3d = info._3d
93 | this._ui.firmware = info.firmwareVersion
94 | this._ui.modelName = info.modelName
95 | this._ui.sdk = info.sdkVersion
96 |
97 | if (window.PalmSystem) {
98 | this._ui.language = window.PalmSystem.locale
99 | if (window.PalmSystem.country) {
100 | try {
101 | var country = JSON.parse(window.PalmSystem.country)
102 | this._ui.country = country.country
103 | } catch(e) { }
104 | }
105 | }
106 | }
107 |
108 | exports.createDevice = function(ui) {
109 | return new Device(ui)
110 | }
111 |
112 | exports.Device = Device
113 |
--------------------------------------------------------------------------------
/platform/webos/dist/.directory:
--------------------------------------------------------------------------------
1 | [Dolphin]
2 | PreviewsShown=true
3 | Timestamp=2017,5,29,1,22,44
4 | Version=3
5 |
--------------------------------------------------------------------------------
/platform/webos/dist/appinfo.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "com.{{ title | default('pureqml') }}.app",
3 | "version": "{{ version | default('1.0.0') }}",
4 | "vendor": "{{ author.name | default('Jhon Doe') if author is defined else 'Jhon Doe' }}",
5 | "type": "web",
6 | "main": "index.html",
7 | "title": "{{ title | default('pureqml') }}",
8 | "bgColor": "{{ iconColor | default('#cccccc') }}",
9 | "bgImage": "preview.png",
10 | "icon": "icon.png",
11 | "largeIcon": "icon.png",
12 | "resolution":"{{ resolutionWidth | default(1280) }}x{{ resolutionHeight | default(720) }}",
13 | "iconColor": "{{ iconColor | default('#eeeeee') }}",
14 | "splashBackground": "splash.png",
15 | "disableBackHistoryAPI":true,
16 | "uiRevision":1
17 | }
18 |
--------------------------------------------------------------------------------
/platform/webos/dist/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/webos/dist/icon.png
--------------------------------------------------------------------------------
/platform/webos/dist/index.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %}
2 | {% block head %}
3 |
4 | {% endblock %}
5 |
--------------------------------------------------------------------------------
/platform/webos/dist/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/webos/dist/preview.png
--------------------------------------------------------------------------------
/platform/webos/dist/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pureqml/qmlcore-tv/86b1710956ea4d977aac3d30671714a2ed50cd09/platform/webos/dist/splash.png
--------------------------------------------------------------------------------
/platform/webos/dist/webOSTVjs-1.1.0/LICENSE-2.0.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/platform/webos/dist/webOSTVjs-1.1.0/webOSTV-dev.js:
--------------------------------------------------------------------------------
1 | window.webOSDev=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:function(){},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(!this.cancelled){var o={};try{o=JSON.parse(n)}catch(e){o={errorCode:-1,errorText:n,returnValue:!1}}var i=o,a=i.errorCode,u=i.returnValue;void 0!==a||!1===u?(o.returnValue=!1,t(o)):(o.returnValue=!0,e(o)),r(o),this.subscribe||this.cancel()}}},{key:"cancel",value:function(){this.cancelled=!0,null!==this.bridge&&(this.bridge.cancel(),this.bridge=null),this.ts&&a[this.ts]&&delete a[this.ts]}}]),e}(),c={request:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=o({service:e},t);return(new s).send(r)}};t.default=c},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.drmAgent=t.DRM=void 0;var o=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:function(){},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};setTimeout(function(){return e(t)},0)},v=function(e){return e.state===l.LOADED&&""!==e.getClientId()},h=function(e,t){var r=t.errorCode,n=void 0===r?s.UNKNOWN_ERROR:r,o=t.errorText,i=void 0===o?"Unknown error.":o,a={errorCode:n,errorText:i};return e.setError(a),a},p=function(e){var t="",r="";switch(e){case c.PLAYREADY:t="application/vnd.ms-playready.initiator+xml",r="urn:dvb:casystemid:19219";break;case c.WIDEVINE:t="application/widevine+xml",r="urn:dvb:casystemid:19156"}return{msgType:t,drmSystemId:r}},m={errorCode:s.CLIENT_NOT_LOADED,errorText:"DRM client is not loaded."},b=function(){function e(t){n(this,e),this.clientId="",this.drmType=t,this.errorCode=s.NOT_ERROR,this.errorText="",this.state=l.UNLOADED}return i(e,[{key:"getClientId",value:function(){return this.clientId}},{key:"getDrmType",value:function(){return this.drmType}},{key:"getErrorCode",value:function(){return this.errorCode}},{key:"getErrorText",value:function(){return this.errorText}},{key:"setError",value:function(e){var t=e.errorCode,r=e.errorText;this.errorCode=t,this.errorText=r}},{key:"isLoaded",value:function(e){var t=this,r=e.onSuccess,n=void 0===r?function(){}:r,i=e.onFailure,u=void 0===i?function(){}:i;d({method:"isLoaded",parameters:{appId:(0,a.fetchAppId)()},onComplete:function(e){if(!0===e.returnValue){if(t.clientId=e.clientId||"",t.state=e.loadStatus?l.LOADED:l.UNLOADED,!0===e.loadStatus&&e.drmType!==t.drmType){var r={errorCode:s.UNKNOWN_ERROR,errorText:"DRM types of set and loaded are not matched."};return u(h(t,r))}var i=o({},e);return delete i.returnValue,n(i)}return u(h(t,e))}})}},{key:"load",value:function(e){var t=this,r=e.onSuccess,n=void 0===r?function(){}:r,o=e.onFailure,i=void 0===o?function(){}:o;if(this.state===l.LOADING||this.state===l.LOADED)return void f(n,{isLoaded:!0,clientId:this.clientId});var u={appId:(0,a.fetchAppId)(),drmType:this.drmType};this.state=l.LOADING,d({method:"load",onComplete:function(e){return!0===e.returnValue?(t.clientId=e.clientId,t.state=l.LOADED,n({clientId:t.clientId})):i(h(t,e))},parameters:u})}},{key:"unload",value:function(e){var t=this,r=e.onSuccess,n=void 0===r?function(){}:r,o=e.onFailure,i=void 0===o?function(){}:o;if(!v(this))return void f(i,h(this,m));var a={clientId:this.clientId};this.state=l.UNLOADING,d({method:"unload",onComplete:function(e){return!0===e.returnValue?(t.clientId="",t.state=l.UNLOADED,n()):i(h(t,e))},parameters:a})}},{key:"getRightsError",value:function(e){var t=this,r=e.onSuccess,n=void 0===r?function(){}:r,i=e.onFailure,a=void 0===i?function(){}:i;if(!v(this))return void f(a,h(this,m));d({method:"getRightsError",parameters:{clientId:this.clientId,subscribe:!0},onComplete:function(e){if(!0===e.returnValue){var r=o({},e);return delete r.returnValue,n(r)}return a(h(t,e))}})}},{key:"sendDrmMessage",value:function(e){var t=this,r=e.msg,n=void 0===r?"":r,i=e.onSuccess,a=void 0===i?function(){}:i,u=e.onFailure,s=void 0===u?function(){}:u;if(!v(this))return void f(s,h(this,m));var c=p(this.drmType),l=o({clientId:this.clientId,msg:n},c);d({method:"sendDrmMessage",onComplete:function(e){if(!0===e.returnValue){var r=o({},e);return delete r.returnValue,a(r)}return s(h(t,e))},parameters:l})}}]),e}();t.DRM={Error:s,Type:c},t.drmAgent=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return""===e?null:new b(e)};t.default=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){var t=e.onSuccess,r=void 0===t?function(){}:t,o=e.onFailure,i=void 0===o?function(){}:o;if(-1===navigator.userAgent.indexOf("Chrome"))return void setTimeout(function(){return i({errorCode:"ERROR.000",errorText:"Not supported."})},0);(new n.LS2Request).send({service:"luna://com.webos.service.sm",method:"deviceid/getIDs",parameters:{idType:["LGUDID"]},onComplete:function(e){if(!0===e.returnValue){var t=e.idList.filter(function(e){return"LGUDID"===e.idType})[0].idValue;return void r({id:t})}i({errorCode:e.errorCode,errorText:e.errorText})}})};t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.launchParams=t.launch=t.APP=void 0;var n=Object.assign||function(e){for(var t=1;t-1&&(s="palm"),i({service:"luna://com."+s+".connectionmanager",subscribe:u,onSuccess:r,onFailure:o})}};t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=t.fetchAppId=function(){return window.PalmSystem&&window.PalmSystem.identifier?window.PalmSystem.identifier.split(" ")[0]:""},o={};t.fetchAppInfo=function(e,t){if(0===Object.keys(o).length){var r=function(t,r){if(!t&&r)try{o=JSON.parse(r),e&&e(o)}catch(t){console.error("Unable to parse appinfo.json file for",n()),e&&e()}else e&&e()},i=new window.XMLHttpRequest;i.onreadystatechange=function(){4===i.readyState&&(i.status>=200&&i.status<300||0===i.status?r(null,i.responseText):r({status:404}))};try{i.open("GET",t||"appinfo.json",!0),i.send(null)}catch(e){r({status:404})}}else e&&e(o)},t.fetchAppRootPath=function(){var e=window.location.href;if("baseURI"in window.document)e=window.document.baseURI;else{var t=window.document.getElementsByTagName("base");t.length>0&&(e=t[0].href)}var r=e.match(new RegExp(".*://[^#]*/"));return r?r[0]:""},t.platformBack=function(){if(window.PalmSystem&&window.PalmSystem.platformBack)return window.PalmSystem.platformBack()}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.LGUDID=t.launchParams=t.launch=t.drmAgent=t.DRM=t.connection=t.APP=void 0;var o=r(3),i=r(1),a=r(4),u=n(a),s=r(2),c=n(s);t.APP=o.APP,t.connection=u.default,t.DRM=i.DRM,t.drmAgent=i.drmAgent,t.launch=o.launch,t.launchParams=o.launchParams,t.LGUDID=c.default}]);
--------------------------------------------------------------------------------
/platform/webos/dist/webOSTVjs-1.1.0/webOSTV.js:
--------------------------------------------------------------------------------
1 | window.webOS=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=7)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o={};if("object"===("undefined"==typeof window?"undefined":r(window))&&window.PalmSystem)if(window.navigator.userAgent.indexOf("SmartWatch")>-1)o.watch=!0;else if(window.navigator.userAgent.indexOf("SmartTV")>-1||window.navigator.userAgent.indexOf("Large Screen")>-1)o.tv=!0;else{try{var i=JSON.parse(window.PalmSystem.deviceInfo||"{}");if(i.platformVersionMajor&&i.platformVersionMinor){var s=Number(i.platformVersionMajor),a=Number(i.platformVersionMinor);s<3||3===s&&a<=0?o.legacy=!0:o.open=!0}}catch(e){o.open=!0}window.Mojo=window.Mojo||{relaunch:function(){}},window.PalmSystem.stageReady&&window.PalmSystem.stageReady()}else o.unknown=!0;t.default=o},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:function(){},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(!this.cancelled){var o={};try{o=JSON.parse(r)}catch(e){o={errorCode:-1,errorText:r,returnValue:!1}}var i=o,s=i.errorCode,a=i.returnValue;void 0!==s||!1===a?(o.returnValue=!1,t(o)):(o.returnValue=!0,e(o)),n(o),this.subscribe||this.cancel()}}},{key:"cancel",value:function(){this.cancelled=!0,null!==this.bridge&&(this.bridge.cancel(),this.bridge=null),this.ts&&s[this.ts]&&delete s[this.ts]}}]),e}(),u={request:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=o({service:e},t);return(new c).send(n)}};t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.fetchAppId=function(){return window.PalmSystem&&window.PalmSystem.identifier?window.PalmSystem.identifier.split(" ")[0]:""},o={};t.fetchAppInfo=function(e,t){if(0===Object.keys(o).length){var n=function(t,n){if(!t&&n)try{o=JSON.parse(n),e&&e(o)}catch(t){console.error("Unable to parse appinfo.json file for",r()),e&&e()}else e&&e()},i=new window.XMLHttpRequest;i.onreadystatechange=function(){4===i.readyState&&(i.status>=200&&i.status<300||0===i.status?n(null,i.responseText):n({status:404}))};try{i.open("GET",t||"appinfo.json",!0),i.send(null)}catch(e){n({status:404})}}else e&&e(o)},t.fetchAppRootPath=function(){var e=window.location.href;if("baseURI"in window.document)e=window.document.baseURI;else{var t=window.document.getElementsByTagName("base");t.length>0&&(e=t[0].href)}var n=e.match(new RegExp(".*://[^#]*/"));return n?n[0]:""},t.platformBack=function(){if(window.PalmSystem&&window.PalmSystem.platformBack)return window.PalmSystem.platformBack()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(o),s={},a=function(e){if(0===Object.keys(s).length){try{var t=JSON.parse(window.PalmSystem.deviceInfo);s.modelName=t.modelName,s.version=t.platformVersion,s.versionMajor=t.platformVersionMajor,s.versionMinor=t.platformVersionMinor,s.versionDot=t.platformVersionDot,s.sdkVersion=t.platformVersion,s.screenWidth=t.screenWidth,s.screenHeight=t.screenHeight}catch(e){s.modelName="webOS Device"}s.screenHeight=s.screenHeight||window.screen.height,s.screenWidth=s.screenWidth||window.screen.width,i.default.tv&&(new r.LS2Request).send({service:"luna://com.webos.service.tv.systemproperty",method:"getSystemInfo",parameters:{keys:["firmwareVersion","modelName","sdkVersion","UHD"]},onSuccess:function(t){if(s.modelName=t.modelName||s.modelName,s.sdkVersion=t.sdkVersion||s.sdkVersion,s.uhd="true"===t.UHD,t.firmwareVersion&&"0.0.0"!==t.firmwareVersion||(t.firmwareVersion=t.sdkVersion),t.firmwareVersion){s.version=t.firmwareVersion;for(var n=s.version.split("."),r=["versionMajor","versionMinor","versionDot"],o=0;o 1) {
64 | switch (param[0].trim().toLowerCase()) {
65 | case "bandwidth":
66 | track.bandwidth = param[1].trim()
67 | break
68 | case "audio":
69 | track.audio = param[1].trim().replace(/"/g, "")
70 | break
71 | case "resolution":
72 | var size = param[1].split("x")
73 | track.width = size[0]
74 | track.height = size[1]
75 | break
76 | }
77 | }
78 | }
79 | var key = track.width + "x" + track.height
80 | if (!this._totalTracks[key]) {
81 | this._totalTracks[key] = []
82 | }
83 | this._totalTracks[key].push(track)
84 | } else if (line.indexOf('#EXT-X-MEDIA:TYPE=AUDIO') == 0) {
85 | var attributes = line.split(',');
86 | var audioTrack = {}
87 | for (var j = 0; j < attributes.length; ++j) {
88 | var param = attributes[j].split('=');
89 | if (param.length > 1) {
90 | switch (param[0].trim().toLowerCase()) {
91 | case "group-id":
92 | audioTrack.id = param[1].trim().replace(/"/g, "")
93 | break
94 | case "name":
95 | audioTrack.label = param[1].trim().replace(/"/g, "")
96 | break
97 | case "language":
98 | audioTrack.language = param[1].trim().replace(/"/g, "")
99 | break
100 | case "uri":
101 | audioTrack.url = param[1].trim()
102 | break
103 | }
104 | }
105 | }
106 | this._audioTracksInfo.push(audioTrack)
107 | }
108 | }
109 |
110 | for (var i in this._totalTracks) {
111 | var tmpTrack = this._totalTracks[i][0]
112 | tmpTrack.id = ++idx
113 | this._videoTracks.push(tmpTrack)
114 | }
115 | }
116 |
117 | Player.prototype.setDrmSource = function(source) {
118 | log("playDrmSource", this._drmClientId, "type", this._drmType)
119 | var options = {};
120 | options.option = {};
121 | options.option.drm = {};
122 |
123 | var extension = this._extension
124 | var type = ""
125 | if (extension === ".m3u8" || extension === ".m3u") {
126 | options.mediaTransportType = "HLS";
127 | type = "application/x-mpegURL"
128 | } else if (extension === ".mpd") {
129 | type = "application/dash+xml"
130 | } else if (extension === ".mp4") {
131 | type = "video/mp4"
132 | options.mediaTransportType = "URI";
133 | } else {
134 | type = "application/vnd.ms-sstr+xml"
135 | }
136 |
137 | if (this._drmType == "widevine") {
138 | options.mediaTransportType = "WIDEVINE";
139 | options.option.drm.type = "widevine";
140 | options.option.drm.clientId = this._drmClientId;
141 | } else if (this._drmType == "playready") {
142 | options.option.drm.type = "playready";
143 | options.option.drm.clientId = this._drmClientId;
144 | }
145 |
146 | if (this._startBitrate) {
147 | options.option.adaptiveStreaming = { }
148 | options.option.adaptiveStreaming.bps = { }
149 | options.option.adaptiveStreaming.bps.start = this._startBitrate
150 | }
151 |
152 | var mediaOption = encodeURIComponent(JSON.stringify(options));
153 | var ui = this.ui
154 | var sourceElement = this._sourceElement ? this._sourceElement : ui._context.createElement('source')
155 | sourceElement.setAttribute('src', source + (ui.startPosition ? "#t=" + ui.startPosition : ""));
156 | sourceElement.setAttribute('type', type + ';mediaOption=' + mediaOption);
157 |
158 | if (!this._sourceElement)
159 | ui.element.append(sourceElement);
160 | this._sourceElement = sourceElement
161 | this.element.dom.load()
162 | this.element.dom.play()
163 | }
164 |
165 | Player.prototype.getVideoTracks = function() {
166 | return this._videoTracks || []
167 | }
168 |
169 | Player.prototype.getAudioTracks = function() {
170 | var audioTracks = this.element.dom.audioTracks
171 | var result = []
172 | for (var i = 0; i < audioTracks.length; ++i) {
173 | var track = audioTracks[i]
174 | var info = this._audioTracksInfo ? this._audioTracksInfo[i] : null
175 | result.push({
176 | "id": i,
177 | "name": track.label ? track.label : (info ? info.name : "Unknown"),
178 | "language": track.language ? track.language : (info ? info.language : "Unknown")
179 | })
180 | }
181 | log("getAudioTracks", result)
182 | return result
183 | }
184 |
185 | Player.prototype.setAudioTrack = function(trackId) {
186 | var audioTracks = this.element.dom.audioTracks
187 | if (trackId < 0 || trackId >= audioTracks.length) {
188 | log("Where is no track", trackId)
189 | return
190 | }
191 | log("Set audio track", audioTracks[trackId])
192 |
193 | var result = []
194 | for (var i = 0; i < audioTracks.length; ++i)
195 | audioTracks[i].enabled = i === trackId
196 | }
197 |
198 | Player.prototype.setVideoTrack = function(trackId) {
199 | if (!this._videoTracks || this._videoTracks.length <= 0) {
200 | log("There is no available video track", this._videoTracks)
201 | return
202 | }
203 | if (trackId < 0 || trackId >= this._videoTracks.length) {
204 | log("Track with id", trackId, "not found")
205 | return
206 | }
207 | var ui = this.ui
208 | ui.waiting = true
209 | var progress = this.ui.progress
210 | log("Set video", this._videoTracks[trackId])
211 | this.element.dom.src = this._videoTracks[trackId].url + (ui.startPosition ? "#t=" + ui.startPosition : "")
212 | this._seekAfterSwitchProgress = progress
213 | }
214 |
215 | Player.prototype.playOptionType = function(source, type) {
216 | log("playOptionType", type, "Src", source)
217 | var ui = this.ui
218 | var sourceElement = this._sourceElement ? this._sourceElement : ui._context.createElement('source')
219 |
220 | var mediaOption = ""
221 | if (this._startBitrate) {
222 | var options = {};
223 | options.option = {};
224 | options.option.drm = {};
225 | options.option.adaptiveStreaming = { }
226 | options.option.adaptiveStreaming.bps = { }
227 | options.option.adaptiveStreaming.bps.start = this._startBitrate
228 | mediaOption = encodeURIComponent(JSON.stringify(options));
229 | }
230 |
231 | sourceElement.setAttribute('src', source + (ui.startPosition ? "#t=" + ui.startPosition : ""));
232 | sourceElement.setAttribute('type', type + (mediaOption ? ';mediaOption=' + mediaOption : ""));
233 |
234 | if (!this._sourceElement)
235 | ui.element.append(sourceElement);
236 |
237 | this._sourceElement = sourceElement
238 | this.element.dom.load()
239 | this.element.dom.play()
240 | }
241 |
242 | Player.prototype.playDashUrl = function(source) {
243 | this.playOptionType(source, "application/dash+xml");
244 | }
245 |
246 | Player.prototype.playMp4 = function(source) {
247 | this.playOptionType(source, "video/mp4");
248 | }
249 |
250 | Player.prototype.playSmoothStreamsingUrl = function(source) {
251 | this.playOptionType(source, "application/vnd.ms-sstr+xml");
252 | }
253 |
254 | Player.prototype.getFileExtension = function(filePath) {
255 | if (!filePath)
256 | return ""
257 | var urlLower = filePath.toLowerCase()
258 | var querryIndex = filePath.indexOf("?")
259 | if (querryIndex >= 0)
260 | urlLower = urlLower.substring(0, querryIndex)
261 | var extIndex = urlLower.lastIndexOf(".")
262 | return urlLower.substring(extIndex, urlLower.length)
263 | }
264 |
265 | Player.prototype.setSource = function(url) {
266 | var ui = this.ui
267 | ui.ready = false
268 | ui.seeking = false
269 | ui.waiting = false
270 | ui.duration = 0
271 | this._extension = this.getFileExtension(url)
272 | log("Set source", url, "ext", this._extension)
273 |
274 | if (!url) {
275 | this.element.dom.removeAttribute('src');
276 | } else if (this._drmClientId) {
277 | this.setDrmSource(url)
278 | } else if (this._extension === ".mpd") {
279 | this.playDashUrl(url)
280 | } else if (this._extension === ".mp4") {
281 | this.playMp4(url)
282 | } else if (this._extension === ".m3u8" || this._extension === ".m3u") {
283 | if (url) {
284 | this._xhr.open('GET', url);
285 | this._xhr.send()
286 | }
287 | this.element.dom.src = url + (ui.startPosition ? "#t=" + ui.startPosition : "")
288 | } else if (this._extension.indexOf("manifest") >= 0) {
289 | this.playSmoothStreamsingUrl(url)
290 | } else {
291 | this.element.dom.src = url + (ui.startPosition ? "#t=" + ui.startPosition : "")
292 | }
293 | }
294 |
295 | Player.prototype.pause = function() {
296 | var ui = this.ui
297 | if (!ui)
298 | return
299 |
300 | log("Player pause waiting:", ui.waiting, "seeking", ui.seeking)
301 | if (!ui.waiting && !ui.seeking)
302 | this.element.dom.pause()
303 | }
304 |
305 | Player.prototype.lunaRequestImpl = function(serviceUri, requestObject) {
306 | if (!window.webOS) {
307 | log("webOS not found! Maybe you forget to include webOS.js.")
308 | return
309 | }
310 | window.webOS.service.request(serviceUri, requestObject)
311 | }
312 |
313 | Player.prototype.lunaFillRequest = function(method, args, success, error, complete) {
314 | var res = {
315 | method: method,
316 | parameters: args,
317 | onSuccess: function(response) { success(response) }
318 | }
319 |
320 | if (error)
321 | res.onFailure = function(response) { error(response) }
322 |
323 | if (complete)
324 | res.onComplete = function(response) { complete(response) }
325 |
326 | if (args.subscribe)
327 | res['subscribe'] = args.subscribe
328 |
329 | if (args.resubscribeStatus)
330 | res['resubscribeStatus'] = args.resubscribeStatus
331 |
332 | return res;
333 | }
334 |
335 | Player.prototype.createDrmClient = function(options, callback, error) {
336 | var request = this.lunaFillRequest("load", options, callback, error)
337 | this.lunaRequestImpl("luna://com.webos.service.drm", request)
338 | }
339 |
340 | Player.prototype.sendDrmMessage = function(options, callback, error) {
341 | var request = this.lunaFillRequest("sendDrmMessage", options, callback, error)
342 | this.lunaRequestImpl("luna://com.webos.service.drm", request)
343 | }
344 |
345 | Player.prototype.unloadDrmClient = function(clientId, callback, error) {
346 | var request = this.lunaFillRequest("unload", { "clientId": clientId }, callback, error)
347 | this.lunaRequestImpl("luna://com.webos.service.drm", request)
348 | }
349 |
350 | Player.prototype.subscribeLicensingError = function(options, callback, error) {
351 | var request = this.lunaFillRequest("getRightsError", options, callback, error)
352 | this.lunaRequestImpl("luna://com.webos.service.drm", request)
353 | }
354 |
355 | Player.prototype.getDrmClientId = function(type, callback) {
356 | var self = this
357 | var appId = "com." + ($manifest$title || "pureqml") + ".app"
358 | this.createDrmClient(
359 | { "drmType": type, "appId": appId },
360 | function(result) {
361 | log("DRM Client created", result)
362 | self._drmClientId = result.clientId
363 | self._drmType = type
364 | callback(result.clientId)
365 | }.bind(this),
366 | function(result) {
367 | log("Failed to create client id Error[" + result.errorCode + "]", result.errorText)
368 | }
369 | );
370 | }
371 |
372 | Player.prototype.setupDrm = function(type, options, callback) {
373 | var self = this
374 | this.getDrmClientId(type, function(clientId) {
375 | var msg
376 | var msgType
377 | var drmSystemId
378 |
379 | if (type == "playready") {
380 | msg = '' +
381 | '' +
382 | '' +
383 | '' + (options.laServer || "") + '' +
384 | '' + (options.contentId || "") + '' +
385 | '' +
386 | ''
387 |
388 | msgType = "application/vnd.ms-playready.initiator+xml";
389 | drmSystemId = "urn:dvb:casystemid:19219";
390 | } else if (type == "widevine") {
391 | msg = '' +
392 | '' +
393 | '' + (options.contentUrl || "") + '' +
394 | '' +
395 | '' +
396 | '' +
397 | '' + (options.laServer || "") + '' +
398 | '' +
399 | '' +
400 | '0' +
401 | '' +
402 | '' +
403 | '' +
404 | '' +
405 | '' +
406 | ''
407 |
408 | msgType = "application/widevine+xml";
409 | drmSystemId = "urn:dvb:casystemid:19156";
410 | } else {
411 | throw new Error("Unknown or unsupported DRM type", type)
412 | }
413 |
414 | settings = {
415 | "clientId": clientId,
416 | "msgType": msgType,
417 | "msg": msg,
418 | "drmSystemId": drmSystemId
419 | }
420 |
421 | self.sendDrmMessage(settings, function(result) {
422 | log("sendDrmMessage succeeded", result, "type", type);
423 | if (type == "widevine") {
424 | if (callback)
425 | callback(clientId)
426 | return
427 | }
428 | var msgId = result.msgId;
429 | var resultCode = result.resultCode;
430 | var resultMsg = result.resultMsg;
431 | log("Message ID: " + msgId);
432 | log("[" + resultCode + "] " + resultMsg);
433 |
434 | // FIXME: callback triggered from previous requests
435 | // self.subscribeLicensingError({ "clientId": clientId, "subscribe": true },
436 | // function(result) {
437 | // log("Subscrivelive", result)
438 | // var contentId = result.contentId;
439 | // if (contentId == msgId) {
440 | // if (0 == result.errorState) {
441 | // log("No license");
442 | // } else if ( 1 == result.errorState) {
443 | // log("Invalid license");
444 | // }
445 | // log("DRM System ID: " + result.drmSystemId);
446 | // log("License Server URL: " + result.rightIssueUrl);
447 | // }
448 | // },
449 | // function(result) {
450 | // log("Lisence[" + result.errorCode + "] " + result.errorText);
451 | // }
452 | // )
453 |
454 | switch (resultCode) {
455 | case 0:
456 | log("The action(s) requested by sendDrmMessage() completed successfully");
457 | if (callback)
458 | callback(clientId)
459 | break
460 | case 2:
461 | log("Cannot Process Request: sendDrmMessage() failed because the DRM agent was unable to complete the necessary computations in the time allotted");
462 | break
463 | case 3:
464 | log("Unknown MIME Type: sendDrmMessage() failed, because the specified MIME type is unknown for the specified DRM system indicated in the MIME type");
465 | break
466 | case 4:
467 | log("User Consent Needed sendDrmMessage() failed because user consent is needed for that action");
468 | break
469 | case 1:
470 | default:
471 | log("Unknown Error: sendDrmMessage() failed because an unspecified error occurred.");
472 | break
473 | }
474 | })
475 | }.bind(this));
476 | }
477 |
478 | exports.createPlayer = function(ui) {
479 | return new Player(ui)
480 | }
481 |
482 | exports.probeUrl = function(url) {
483 | return 175
484 | }
485 |
--------------------------------------------------------------------------------