B4J Question Video on WebView Question

Discussion in 'B4J Questions' started by giga, Jun 22, 2015.

  1. giga

    giga Well-Known Member Licensed User

    Is it possible to play a youtube video directly in webview without downloading it?

    or does this require the youtube api to make it work?

    Thanks for any advice.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Have you tried it? Did it work?
     
  3. giga

    giga Well-Known Member Licensed User

    Yes I tried directly through webview and the entire youtube screen appears with the ads etc... but the video windows states "an error occurred" Please try again later

    as you can see here:


    . upload_2015-6-22_1-5-36.png

    If I copy the entire address and paste it in I.E or Mozilla it comes up and plays.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I see it too. I'm not sure whether YouTube is blocking it for some reason or that it is a problem in JavaFX WebView.
     
  5. giga

    giga Well-Known Member Licensed User

    What is the current version of webview? Maybe that is the problem.

    I could not get this to work either.
    Code:
    JViewWeb.LoadUrl("http://www.cnn.com")
    it comes up blank white.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There is no version to WebView. It uses the native WebView (same version as the installed JRE).
     
  7. giga

    giga Well-Known Member Licensed User

  8. Daestrum

    Daestrum Well-Known Member Licensed User

    To play a video from youtube , you can fire up chrome with jShell and get that to play the video
    Code:
    Sub Process_Globals
        
    Private fx As JFX
        
    Private MainForm As Form
        
    Dim jsh As Shell
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)
        jsh.InitializeDoNotHandleQuotes(
    "jsh","C:/the/really/long/pathname/to/where/chrome/is/chrome.exe",Array("--app=https://www.youtube.com/embed/CTNJ51ghzdY"))
        jsh.Run(-
    1)
    End Sub
    The above will play the video in a chrome window that has no address bar etc
     
    giga likes this.
  9. giga

    giga Well-Known Member Licensed User

    Thanks @Daestrum Your code is an alternative and works great. My problem is if the user does not have chrome installed it won't work. I could also use jshell with iexplore.exe but I was hoping to keep the video in the app.
     
  10. jmon

    jmon Well-Known Member Licensed User

    Playing videos from DailyMotion works
    Code:
    wv.LoadUrl("http://www.dailymotion.com/video/x2oa18s_une-video-amateur-montre-le-moment-ou-le-seisme-a-frappe-le-tibet_news")

    '
    wv.LoadHtml($"<iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/x2bi11w" allowfullscreen></iframe><br /><a href="http://www.dailymotion.com/video/x2bi11w_un-sinkhole-engloutit-une-voiture-sur-une-route-de-chine_news" target="_blank">Un &quot;sinkhole&quot; engloutit une voiture sur une...</a> <i>by <a href="http://www.dailymotion.com/lemondefr" target="_blank">lemondefr</a></i>"$)
    but I tried Vimeo and Youtube, no luck....
     
  11. giga

    giga Well-Known Member Licensed User

Loading...