On Friday, December 2, 2016 at 2:06:41 PM UTC, Rex van der Spuy wrote: > Hi Everyone! > > I'm hoping you can all help me figure out the best strategy to handle this > problem: > It's probably not complicated, but I would love to hear your ideas on the > best solution. > > I have a video tag in my `view` that looks like this: > > ``` > video [ width 400, height 300, autoplay True, loop True ] [ source [ src > "video/general.mp4" ] [ ] ] > ``` > > When it's finished, I want another video to start playing automatically. > I know that in JavaScript you can listen for an `ended` event ( > http://stackoverflow.com/questions/2741493/detect-when-an-html5-video-finishes > ) > But how do you handle this in Elm? > Would I need to listen for this using ports, or is there some way to > trigger trigger the `update` function directly in Elm? > Maybe with a subscription to a port:
app = Elm.Main.fullscreen(); app.ports.videoEnded.send(something); Then in Elm: port videoEnded : (Type of something -> msg) -> Sub msg Replacing something with any data you want to pass to the port, or perhaps () if you don't need anything to be passed. You will use this data to add to the elm event, or an event with no args if not passing anything. Subscribe to the port: subscriptions : Model -> Sub Msg subscriptions model = videoEnded (\something -> VideoEnded something) Then hook up the video ending event to call your port on the javascript side. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
