Merge lp:~mvo/software-center/sca-video into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2730
Proposed branch: lp:~mvo/software-center/sca-video
Merge into: lp:software-center
Diff against target: 130 lines (+44/-10)
4 files modified
softwarecenter/backend/spawn_helper.py (+1/-1)
softwarecenter/db/update.py (+4/-0)
softwarecenter/ui/gtk3/views/appdetailsview.py (+1/-1)
softwarecenter/ui/gtk3/widgets/videoplayer.py (+38/-8)
To merge this branch: bzr merge lp:~mvo/software-center/sca-video
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+92244@code.launchpad.net

Description of the change

This make the software-center work with the current video support from the software-center agent.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Fwiw, to test run:
SOFTWARE_CENTER_DISTRO_CODENAME=oneiric PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION=1 SOFTWARE_CENTER_AGENT_HOST=https://sca.testingserver.info ./software-center

and look for "helloy" there (on the right test-server).

lp:~mvo/software-center/sca-video updated
2733. By Michael Vogt

ensure to reset the video url when a new app is displayed

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hey mvo,

I was just looking at this MP for example html to use... are you meaning to re-define the html variable on (MP lines) 109, 113, 115?

Also, with the snippet:

<iframe src="http://player.vimeo.com/video/2891554?title=0&amp;byline=0&amp;portrait=0" width="400" height="308" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><p><a href="http://vimeo.com/2891554">Supertuxkart 0.6</a> from <a href="http://vimeo.com/user1183699">constantin pelikan</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

Should we be including all of that on the server rendered version? (I mean, we won't have the vimeo user id, so I'm hoping it's not all required to satisfy the terms). We can obviously include the link to vimeo itself after the iframe, but I'd assumed that when you were speaking earlier about links, that you meant links within the iframe itself?

Cheers,
M

Revision history for this message
Michael Vogt (mvo) wrote :

Hi Michael, thanks for your review! The code is mean to redfine it, but its pretty confusing, I will update it to have "html_youtube", "html_viemo", "html_dailymotion" to make it clearer. Its just some test code to allow interactive testing but that is no excuse for it being confusing :)

As for the other question - I'm pretty sure we don't need the extra:
"""
<p><a href="http://vimeo.com/2891554">Supertuxkart 0.6</a> from <a href="http://vimeo.com/user1183699">constantin pelikan</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
"""
as you can configure the "embedd" link directly in their UI to remove those elements.

lp:~mvo/software-center/sca-video updated
2734. By Michael Vogt

address comments from Michael Nelson (many thanks!)

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Awesome! And very exciting to get this in!! Thanks mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/spawn_helper.py'
2--- softwarecenter/backend/spawn_helper.py 2012-01-06 05:43:34 +0000
3+++ softwarecenter/backend/spawn_helper.py 2012-02-09 18:58:19 +0000
4@@ -102,7 +102,7 @@
5 if res == 0:
6 self.emit("exited", res)
7 else:
8- LOG.warn("exit code %s from helper" % res)
9+ LOG.warn("exit code %s from helper for '%s'" % (res, self._cmd))
10 # check stderr
11 err = os.read(stderr, 4*1024)
12 self._stderr = err
13
14=== modified file 'softwarecenter/db/update.py'
15--- softwarecenter/db/update.py 2012-02-03 17:23:24 +0000
16+++ softwarecenter/db/update.py 2012-02-09 18:58:19 +0000
17@@ -184,6 +184,10 @@
18 self.sca_application.Description = "\n".join(
19 self.sca_application.description.split("\n")[1:]).strip()
20
21+ # we only support a single video currently :/
22+ if hasattr(self.sca_application, "video_urls"):
23+ self.sca_application.video_url = self.sca_application.video_urls[0]
24+
25 # XXX 2012-01-16 bug=917109
26 # We can remove these work-arounds once the above bug is fixed on
27 # the server. Until then, we fake a channel here and empty category
28
29=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
30--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-02-03 20:07:27 +0000
31+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-02-09 18:58:19 +0000
32@@ -1336,8 +1336,8 @@
33 return
34
35 def _update_app_video(self, app_details):
36+ self.videoplayer.uri = app_details.video_url
37 if app_details.video_url:
38- self.videoplayer.uri = app_details.video_url
39 self.videoplayer.show()
40 else:
41 self.videoplayer.hide()
42
43=== modified file 'softwarecenter/ui/gtk3/widgets/videoplayer.py'
44--- softwarecenter/ui/gtk3/widgets/videoplayer.py 2011-11-22 17:39:58 +0000
45+++ softwarecenter/ui/gtk3/widgets/videoplayer.py 2012-02-09 18:58:19 +0000
46@@ -17,6 +17,7 @@
47 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48
49 import logging
50+import subprocess
51 import sys
52
53 from gettext import gettext as _
54@@ -37,21 +38,40 @@
55 class VideoPlayer(Gtk.VBox):
56 def __init__(self):
57 super(VideoPlayer, self).__init__()
58+ self.set_size_request(400, 400)
59 self.webkit = WebKit.WebView()
60- self.webkit.connect("new-window-policy-decision-requested", self._on_new_window)
61+ settings = self.webkit.get_settings()
62+ # this disables the flash and other plugins so that we force html5
63+ # video on the system. This is works currently (11/2011) fine with
64+ # dailymotion and vimeo but youtube is opt-in only so we need
65+ # to monitor the situation
66+ settings.set_property("enable-plugins", False)
67+ # on navigation/new window etc, just use the proper browser
68+ self.webkit.connect(
69+ "new-window-policy-decision-requested", self._on_new_window)
70+ self.webkit.connect("create-web-view", self._on_create_web_view)
71 self.pack_start(self.webkit, True, True, 0)
72 self._uri = ""
73
74- # helper required to follow ToS about the "back" link
75+ # helper required to follow ToS about the "back" link (flash version)
76 def _on_new_window(self, view, frame, request, action, policy):
77- import subprocess
78 subprocess.Popen(['xdg-open', request.get_uri()])
79 return True
80+ # helper for the embedded html5 viewer
81+ def _on_create_web_view(self, view, frame):
82+ # mvo: this is not ideal, the trouble is that we do not get the
83+ # url that the new view points to until after the view was
84+ # created. But we don't want to be a full blow internal
85+ # webbrowser so we simply go back to the youtube url here
86+ # and the user needs to click "youtube" there again :/
87+ uri = frame.get_uri()
88+ subprocess.Popen(['xdg-open', uri])
89+ return None
90
91 # uri property
92 def _set_uri(self, v):
93- self._uri = v
94- self.webkit.load_uri(v)
95+ self._uri = v or ""
96+ self.webkit.load_uri(self._uri)
97 def _get_uri(self):
98 return self._uri
99 uri = property(_get_uri, _set_uri, None, "uri property")
100@@ -132,17 +152,27 @@
101
102
103 def get_test_videoplayer_window():
104- html = """
105+ # youtube example fragment
106+ html_youtube = """
107 <iframe width="640" height="390" src="http://www.youtube.com/embed/h3oBU0NZJuA" frameborder="0" allowfullscreen></iframe>
108 """
109+ # vimeo example video fragment
110+ html_vimeo = """
111+<iframe src="http://player.vimeo.com/video/2891554?title=0&amp;byline=0&amp;portrait=0" width="400" height="308" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><p><a href="http://vimeo.com/2891554">Supertuxkart 0.6</a> from <a href="http://vimeo.com/user1183699">constantin pelikan</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
112+"""
113+ # dailymotion example video fragment
114+ html_dailymotion = """
115+<iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/xm4ysu"></iframe>"""
116+ html_dailymotion2 = """<iframe frameborder="0" width="480" height="379" src="http://www.dailymotion.com/embed/video/xdiktp"></iframe>"""
117 win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
118 win.set_default_size(500, 400)
119 win.connect("destroy", Gtk.main_quit)
120 player = VideoPlayer()
121 win.add(player)
122 if len(sys.argv) < 2:
123- # player.uri = "http://upload.wikimedia.org/wikipedia/commons/9/9b/Pentagon_News_Sample.ogg"
124- player.load_html_string(html)
125+ #player.uri = "http://upload.wikimedia.org/wikipedia/commons/9/9b/Pentagon_News_Sample.ogg"
126+ #player.uri = "http://people.canonical.com/~mvo/totem.html"
127+ player.load_html_string(html_vimeo)
128 else:
129 player.uri = sys.argv[1]
130 win.show_all()

Subscribers

People subscribed via source and target branches