Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Importing OvenPlayer is undefined even though in debugger it is not. #124

Closed
walsong opened this issue May 24, 2020 · 10 comments
Closed

Importing OvenPlayer is undefined even though in debugger it is not. #124

walsong opened this issue May 24, 2020 · 10 comments

Comments

@walsong
Copy link

walsong commented May 24, 2020

When I import in vue OvenPlayer like this after installing it:

import { OvenPlayer } from 'OvenPlayer'

and then do OvenPlayer("player", {}), I get the error "Type Error: cannot read property create of undefined"
When I do console.log(OvenPlayer), I get 'undefined' also.

However, in the debugger I have access to OvenPlayer which is not undefined but this:
Object {playerList: Array(0), create:, getPlayerList:, ...}

Is the issue with webpack?

@SangwonOh
Copy link
Member

@walsong Hi. Because OvenPlayer is not webpack modularized. Instead of module, OvenPlayer is property of window object. So you can access from debugger. and you can access it simply window.OvenPlayer.

@walsong
Copy link
Author

walsong commented May 25, 2020

@SangwonOh thank you,
I get the following error now:

Uncaught SyntaxError: Unexpected token '<'   ovenplayer.provider.DashProvider~ovenplayer.provider.HlsProvider~ovenplayer.provider.Html5~ovenplaye~2ec193ac-0.9.0.js:1
Error found is:
 {code: 100, message: "Can not load due to unknown reasons.", reason: "Can not load due to unknown reasons.", error: Error: Network error

when I do this: also note that in place of "player", I had this this.$refs.player which did not work either.

My code is as follows:


<div id="player" ref="player"> </div>

this.player = window.OvenPlayer.create("player", {
                sources: [
                {
                    "type": "dash",
                    "file": "https://Manifest300.mpd"
                }
            ]
            });
        this.player.on("error", function(error){
            console.log("Error found is:", error)
        })

@SangwonOh
Copy link
Member

Hi. How did you include scripts? And did you include dashjs?

@walsong
Copy link
Author

walsong commented May 26, 2020

My imports currently look like this:

<script>
import dashjs from 'dashjs'
import { OvenPlayer } from 'OvenPlayer'
.... mounted hooks, destroy etc.
</script>

Also tried this import:
import Dash from '@/libs/dash.all.min.js'
Dash is before ovenplayer as per the documentation

@SangwonOh
Copy link
Member

How about try using <script src='...'></script> in head element.

It seems webpack is not working properly.

http://demo.ovenplayer.com/

@walsong
Copy link
Author

walsong commented May 27, 2020

Same error when I tried this:

<template>
  <div>
        <div id="player"> </div>
    </div>
</template>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.9.3/dash.all.min.js"></script>
<script src="@/libs/ovenplayer.js"></script>
<script>
//import Dash from '@/libs/dash.all.min.js'
//import dashjs from 'dashjs'
//import { OvenPlayer } from 'OvenPlayer'
//var OpenPlayer = require('OvenPlayer').default;
export default {
    mounted() {
        /*
        if (document.getElementById('dash')) return;
        var scriptDash = document.createElement("script");
        scriptDash.src = "https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.9.3/dash.all.min.js";
        scriptDash.id = "dash";
        document.getElementsByTagName('head')[0].appendChild(scriptTagDash);

        var scriptTagOven = document.createElement("script");
        scriptTagOven.src = "@/libs/ovenplayer.js";
        scriptTagOven.id = "my-oven";
        document.getElementsByTagName('head')[0].appendChild(scriptTagOven);
        */
        //Vue.loadScript("@/libs/dash.all.min.js")
        //Vue.loadScript("@/libs/ovenplayer.js")
        this.player = window.OvenPlayer.create("player", {
                sources: [
                {
                    "type": "dash",
                    "file": "https://Manifest100.mpd"
                }
            ]
            });
        this.player.on("error", function(error){
            console.log("Error found is:", error)
        })
    }
}
</script>

@SangwonOh
Copy link
Member

@walsong Hi. Are you making any progress? We could't reproduce the problem.

Our demo page http://demo.ovenplayer.com/ uses the Vuejs partially.

Viewing the source code of demo page may help you to solve the problem.

@walsong
Copy link
Author

walsong commented Jun 7, 2020

Actually, I did not have too much time to spend on solving the problem. I decided to use another player instead. Thanks though, perhaps in a couple of weeks I will have a look again.

@SangwonOh
Copy link
Member

Good luck @walsong . We hope you visit here soon. Thanks.

@timothybean
Copy link

@walsong Can you let me know what other player you used?

Thanks

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

No branches or pull requests

3 participants