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

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

Closed
tomylee001001 opened this issue Aug 4, 2016 · 4 comments
Closed

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

tomylee001001 opened this issue Aug 4, 2016 · 4 comments

Comments

@tomylee001001
Copy link

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

ngOnInit() {
this._videoPlayer =

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

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



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



}

thanks.

@bradmartin
Copy link
Collaborator

You ever get this working? It might some zone issue. I don't do much ng2 sorry.

@tomylee001001
Copy link
Author

i havent find a solution for this yet but if i ever able to upgrade my app to the new version i will try again. Right now (even though i don't like it ) i am getting my video item when user tap the video in my galery page before navigate and writing that video item to my global config to read for the player.

@kazemihabib
Copy link

try set src in ngZone.run:

import {NgZone} from "@angular/core";
export class playerPage {
   constructor(private _ngZone: NgZone){}
    this._ngZone.run(() => {
         //set src here
     });
}

@bradmartin
Copy link
Collaborator

Should work fine with ngZone from everything I've read and @kazemihabib comment above. This has come up on the NS slack channel before also and the solution was the zone stuff (ng2 isn't my specialty yet) 👍

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